mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
|
import { validateSchema } from '../validate';
|
||
|
import { AdminSegmentSchema } from './admin-segment-schema';
|
||
|
|
||
|
test('updateEnvironmentSchema', () => {
|
||
|
const data: AdminSegmentSchema = {
|
||
|
id: 1,
|
||
|
name: 'release',
|
||
|
constraints: [],
|
||
|
createdAt: '2022-07-25 06:00:00',
|
||
|
createdBy: 'test',
|
||
|
description: 'a description',
|
||
|
};
|
||
|
|
||
|
expect(
|
||
|
validateSchema('#/components/schemas/adminSegmentSchema', data),
|
||
|
).toBeUndefined();
|
||
|
|
||
|
expect(
|
||
|
validateSchema('#/components/schemas/adminSegmentSchema', {
|
||
|
id: 1,
|
||
|
name: 'release',
|
||
|
constraints: [],
|
||
|
createdAt: '2022-07-25 06:00:00',
|
||
|
}),
|
||
|
).toBeUndefined();
|
||
|
|
||
|
expect(
|
||
|
validateSchema('#/components/schemas/adminSegmentSchema', {
|
||
|
id: 1,
|
||
|
name: 'release',
|
||
|
constraints: [],
|
||
|
createdAt: '2022-07-25 06:00:00',
|
||
|
additional: 'property',
|
||
|
}),
|
||
|
).toMatchSnapshot();
|
||
|
|
||
|
expect(
|
||
|
validateSchema('#/components/schemas/adminSegmentSchema', {
|
||
|
id: 1,
|
||
|
name: 'release',
|
||
|
constraints: [],
|
||
|
createdAt: 'wrong-format',
|
||
|
}),
|
||
|
).toMatchSnapshot();
|
||
|
|
||
|
expect(
|
||
|
validateSchema('#/components/schemas/adminSegmentSchema', {
|
||
|
name: 'release',
|
||
|
constraints: [],
|
||
|
}),
|
||
|
).toMatchSnapshot();
|
||
|
|
||
|
expect(
|
||
|
validateSchema(
|
||
|
'#/components/schemas/adminSegmentSchema',
|
||
|
'not an object',
|
||
|
),
|
||
|
).toMatchSnapshot();
|
||
|
});
|