test: openapi spec assertions for the world endpoints
This commit is contained in:
+14
-2
@@ -3,8 +3,20 @@ import { describe, expect, it } from 'vitest';
|
|||||||
import { openApiSpec } from './openapi';
|
import { openApiSpec } from './openapi';
|
||||||
|
|
||||||
describe('OpenAPI spec', () => {
|
describe('OpenAPI spec', () => {
|
||||||
it('documents exactly the one public endpoint (scaffold stage)', () => {
|
it('documents every public endpoint', () => {
|
||||||
expect(Object.keys(openApiSpec.paths).sort()).toEqual(['/api/version']);
|
expect(Object.keys(openApiSpec.paths).sort()).toEqual(['/api/jump', '/api/version', '/api/world']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('describes the world endpoints as WorldState in and out', () => {
|
||||||
|
const world = openApiSpec.paths['/api/world'].get.responses[200].content['application/json'].schema;
|
||||||
|
expect(world.$ref).toBe('#/components/schemas/WorldState');
|
||||||
|
|
||||||
|
const jump = openApiSpec.paths['/api/jump'].post;
|
||||||
|
expect(jump.requestBody.content['application/json'].schema.$ref).toBe('#/components/schemas/JumpRequest');
|
||||||
|
expect(jump.responses[200].content['application/json'].schema.$ref).toBe('#/components/schemas/WorldState');
|
||||||
|
for (const status of ['400', '404', '409'] as const) {
|
||||||
|
expect(jump.responses[status].content['application/json'].schema.$ref).toBe('#/components/schemas/Error');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps info.version in sync with package.json', () => {
|
it('keeps info.version in sync with package.json', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user