2022-06-08 08:01:14 +02:00
|
|
|
import { validateSchema } from '../validate';
|
|
|
|
import { FeatureSchema } from './feature-schema';
|
|
|
|
|
|
|
|
test('featureSchema', () => {
|
|
|
|
const data: FeatureSchema = {
|
|
|
|
name: 'a',
|
|
|
|
strategies: [
|
|
|
|
{
|
2022-06-23 08:10:20 +02:00
|
|
|
id: 'a',
|
2022-06-08 08:01:14 +02:00
|
|
|
name: 'a',
|
|
|
|
constraints: [
|
|
|
|
{
|
|
|
|
contextName: 'a',
|
|
|
|
operator: 'IN',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
variants: [
|
|
|
|
{
|
|
|
|
name: 'a',
|
|
|
|
weight: 1,
|
|
|
|
weightType: 'a',
|
|
|
|
stickiness: 'a',
|
|
|
|
overrides: [{ contextName: 'a', values: ['a'] }],
|
|
|
|
payload: { type: 'a', value: 'b' },
|
|
|
|
},
|
|
|
|
],
|
2022-06-08 15:31:34 +02:00
|
|
|
environments: [
|
|
|
|
{
|
|
|
|
name: 'a',
|
|
|
|
type: 'b',
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
],
|
2022-06-08 08:01:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
|
|
|
validateSchema('#/components/schemas/featureSchema', data),
|
|
|
|
).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('featureSchema constraints', () => {
|
|
|
|
const data = {
|
|
|
|
name: 'a',
|
|
|
|
strategies: [{ name: 'a', constraints: [{ contextName: 'a' }] }],
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
|
|
|
validateSchema('#/components/schemas/featureSchema', data),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('featureSchema overrides', () => {
|
|
|
|
const data = {
|
|
|
|
name: 'a',
|
|
|
|
variants: [
|
|
|
|
{
|
|
|
|
name: 'a',
|
|
|
|
weight: 1,
|
|
|
|
weightType: 'a',
|
|
|
|
stickiness: 'a',
|
|
|
|
overrides: [{ contextName: 'a', values: 'b' }],
|
|
|
|
payload: { type: 'a', value: 'b' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
|
|
|
validateSchema('#/components/schemas/featureSchema', data),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|