1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00
unleash.unleash/src/lib/openapi/spec/playground-response-schema.test.ts
Thomas Heartman 012da8469f
feat: add all feature variants to the playground payload (#1835)
* Chore: extract variant creation arbitrary.

* Feat: add "variants" as a required property on playground response

* Wip: fix up some schema generation

* Fix remaining openapi schemas

* Fix: add missing variants property

* Feat: test for variants

* Feat: add `variants` property to playground response

* Chore: update openapi snapshot
2022-07-20 08:54:34 +02:00

27 lines
877 B
TypeScript

import fc, { Arbitrary } from 'fast-check';
import {
playgroundResponseSchema,
PlaygroundResponseSchema,
} from '../../../lib/openapi/spec/playground-response-schema';
import { validateSchema } from '../validate';
import { generate as generateInput } from './playground-request-schema.test';
import { generate as generateFeature } from './playground-feature-schema.test';
const generate = (): Arbitrary<PlaygroundResponseSchema> =>
fc.record({
input: generateInput(),
features: fc.uniqueArray(generateFeature(), {
selector: (feature) => feature.name,
}),
});
test('playgroundResponseSchema', () =>
fc.assert(
fc.property(
generate(),
(data: PlaygroundResponseSchema) =>
validateSchema(playgroundResponseSchema.$id, data) ===
undefined,
),
));