Files
KArtSell.Aegis/docs/Design/kbx-foundation-v60-status-canonical-contract-hardening/tests/unit/kbx-api-contract.spec.ts
T
kjh2064 3f293d8aa8
deploy / deploy (push) Successful in 1m52s
deploy / notify (push) Successful in 1s
V13-FE-006: consolidate approved UI and contract hardening
2026-08-13 02:41:00 +09:00

23 lines
963 B
TypeScript

import { describe, expect, it } from 'vitest'
import { isKbxProblem, kbxApiCatalog } from '@kbx/contracts'
describe('KBX API contract', () => {
it('keeps operation IDs and routes unique', () => {
const operations = Object.values(kbxApiCatalog)
expect(new Set(operations.map(x => x.id)).size).toBe(operations.length)
expect(new Set(operations.map(x => `${x.method} ${x.path}`)).size).toBe(operations.length)
})
it('requires a stable key only for mutation operations', () => {
const required = Object.values(kbxApiCatalog).filter(x => x.idempotency === 'required')
expect(required.length).toBeGreaterThan(0)
expect(required.every(x => x.method !== 'GET')).toBe(true)
})
it('recognizes the public problem discriminator family', () => {
for (const type of ['validation','business-rule','conflict','permission','not-found','integration','system']) {
expect(isKbxProblem({ type, title: 'test' })).toBe(true)
}
})
})