Files
forgery/src/api/asset.test.ts
T
google-labs-jules[bot] 299be74d66 feat: backend infra setup with prisma, services, and apis
- Added Prisma schema with Asset, Character, Equipment, Generation, Category models
- Configured SQLite with LibSQL adapter
- Implemented Service layer (src/service) with unit tests
- Implemented API layer (src/api) with Hono and integration tests
- Added static file serving for assets
- Configured CI/CD with GitHub Actions
- Added Developer Guide (AGENTS.md)
2026-02-07 12:32:56 +00:00

35 lines
937 B
TypeScript

import { describe, it, expect, mock, afterEach } from 'bun:test'
import asset from './asset'
const mockAssetService = {
createAsset: mock(),
}
mock.module('../service/asset', () => ({
AssetService: mockAssetService,
}))
describe('Asset API', () => {
afterEach(() => {
mockAssetService.createAsset.mockClear()
})
it('POST /upload should create asset', async () => {
mockAssetService.createAsset.mockResolvedValue({ id: '1', name: 'Test' })
const formData = new FormData()
formData.append('file', new File(['test'], 'test.png', { type: 'image/png' }))
formData.append('name', 'Test Asset')
const req = new Request('http://localhost/upload', {
method: 'POST',
body: formData,
})
const res = await asset.fetch(req)
expect(res.status).toBe(201)
expect(await res.json()).toEqual({ id: '1', name: 'Test' })
expect(mockAssetService.createAsset).toHaveBeenCalled()
})
})