mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
1ed8dd0f0d
* refactor: add OpenAPI schema to constraints controller * refactor: add more schema tests
35 lines
879 B
TypeScript
35 lines
879 B
TypeScript
import { validateSchema } from '../validate';
|
|
import { ConstraintSchema } from './constraint-schema';
|
|
|
|
test('constraintSchema', () => {
|
|
const data: ConstraintSchema = {
|
|
contextName: 'a',
|
|
operator: 'NUM_LTE',
|
|
value: '1',
|
|
};
|
|
|
|
expect(
|
|
validateSchema('#/components/schemas/constraintSchema', data),
|
|
).toBeUndefined();
|
|
});
|
|
|
|
test('constraintSchema invalid value type', () => {
|
|
expect(
|
|
validateSchema('#/components/schemas/constraintSchema', {
|
|
contextName: 'a',
|
|
operator: 'NUM_LTE',
|
|
value: 1,
|
|
}),
|
|
).toMatchSnapshot();
|
|
});
|
|
|
|
test('constraintSchema invalid operator name', () => {
|
|
expect(
|
|
validateSchema('#/components/schemas/constraintSchema', {
|
|
contextName: 'a',
|
|
operator: 'b',
|
|
value: '1',
|
|
}),
|
|
).toMatchSnapshot();
|
|
});
|