mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
28 lines
912 B
TypeScript
28 lines
912 B
TypeScript
|
import fc, { Arbitrary } from 'fast-check';
|
||
|
import { validateSchema } from '../validate';
|
||
|
import { SdkContextSchema, sdkContextSchema } from './sdk-context-schema';
|
||
|
import { commonISOTimestamp } from '../../../test/arbitraries.test';
|
||
|
|
||
|
export const generate = (): Arbitrary<SdkContextSchema> =>
|
||
|
fc.record(
|
||
|
{
|
||
|
appName: fc.string({ minLength: 1 }),
|
||
|
currentTime: commonISOTimestamp(),
|
||
|
environment: fc.string(),
|
||
|
properties: fc.dictionary(fc.string(), fc.string()),
|
||
|
remoteAddress: fc.ipV4(),
|
||
|
sessionId: fc.uuid(),
|
||
|
userId: fc.emailAddress(),
|
||
|
},
|
||
|
{ requiredKeys: ['appName'] },
|
||
|
);
|
||
|
|
||
|
test('sdkContextSchema', () =>
|
||
|
fc.assert(
|
||
|
fc.property(
|
||
|
generate(),
|
||
|
(data: SdkContextSchema) =>
|
||
|
validateSchema(sdkContextSchema.$id, data) === undefined,
|
||
|
),
|
||
|
));
|