- 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)
32 lines
870 B
TypeScript
32 lines
870 B
TypeScript
import { describe, it, expect, mock, afterEach } from 'bun:test'
|
|
import generation from './generation'
|
|
|
|
const mockGenerationService = {
|
|
listGenerations: mock(),
|
|
}
|
|
|
|
mock.module('../service/generation', () => ({
|
|
GenerationService: mockGenerationService,
|
|
}))
|
|
|
|
describe('Generation API', () => {
|
|
afterEach(() => {
|
|
mockGenerationService.listGenerations.mockClear()
|
|
})
|
|
|
|
it('GET / should list generations with filters', async () => {
|
|
mockGenerationService.listGenerations.mockResolvedValue({ items: [], total: 0 })
|
|
|
|
const req = new Request('http://localhost/?equipmentId=eq1', {
|
|
method: 'GET',
|
|
})
|
|
|
|
const res = await generation.fetch(req)
|
|
expect(res.status).toBe(200)
|
|
expect(mockGenerationService.listGenerations).toHaveBeenCalledWith(
|
|
{ page: 1, limit: 10 },
|
|
{ characterId: undefined, equipmentId: 'eq1' },
|
|
)
|
|
})
|
|
})
|