mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
|
import fc, { Arbitrary } from 'fast-check';
|
||
|
import { urlFriendlyString } from '../../../test/arbitraries.test';
|
||
|
import {
|
||
|
playgroundRequestSchema,
|
||
|
PlaygroundRequestSchema,
|
||
|
} from '../../../lib/openapi/spec/playground-request-schema';
|
||
|
import { validateSchema } from '../validate';
|
||
|
import { generate as generateContext } from './sdk-context-schema.test';
|
||
|
|
||
|
export const generate = (): Arbitrary<PlaygroundRequestSchema> =>
|
||
|
fc.record({
|
||
|
environment: fc.oneof(
|
||
|
fc.constantFrom('development', 'production', 'default'),
|
||
|
fc.lorem({ maxCount: 1 }),
|
||
|
),
|
||
|
projects: fc.oneof(
|
||
|
fc.uniqueArray(
|
||
|
fc.oneof(fc.lorem({ maxCount: 1 }), urlFriendlyString()),
|
||
|
),
|
||
|
fc.constant('*' as '*'),
|
||
|
),
|
||
|
context: generateContext(),
|
||
|
});
|
||
|
|
||
|
test('playgroundRequestSchema', () =>
|
||
|
fc.assert(
|
||
|
fc.property(
|
||
|
generate(),
|
||
|
(data: PlaygroundRequestSchema) =>
|
||
|
validateSchema(playgroundRequestSchema.$id, data) === undefined,
|
||
|
),
|
||
|
));
|