1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/lib/openapi/index.test.ts

53 lines
1.3 KiB
TypeScript
Raw Normal View History

import {
createOpenApiSchema,
createRequestSchema,
createResponseSchema,
removeJsonSchemaProps,
} from './index';
test('createRequestSchema', () => {
expect(createRequestSchema('schemaName')).toMatchInlineSnapshot(`
Object {
"content": Object {
"application/json": Object {
"schema": Object {
"$ref": "#/components/schemas/schemaName",
},
},
},
"description": "schemaName",
"required": true,
}
`);
});
test('createResponseSchema', () => {
expect(createResponseSchema('schemaName')).toMatchInlineSnapshot(`
Object {
"content": Object {
"application/json": Object {
"schema": Object {
"$ref": "#/components/schemas/schemaName",
},
},
},
"description": "schemaName",
}
`);
});
test('removeJsonSchemaProps', () => {
expect(removeJsonSchemaProps({ a: 'b', $id: 'c', components: {} }))
.toMatchInlineSnapshot(`
Object {
"a": "b",
}
`);
});
test('createOpenApiSchema url', () => {
expect(createOpenApiSchema('https://example.com').servers[0].url).toEqual(
'https://example.com',
);
});