mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
a607dea284
* OAS for client-api metrics.ts * Fix PR comments * Fix PR comments * Fix test * Renamed and synced with proxy * Renamed and synced with proxy * Renamed and synced with proxy * add tests * Update python.md Revert doc * added 400 response, more tests * PR comment * PR comment
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { validateSchema } from '../validate';
|
|
import { ClientMetricsSchema } from './client-metrics-schema';
|
|
|
|
test('clientMetricsSchema full', () => {
|
|
const data: ClientMetricsSchema = {
|
|
appName: 'a',
|
|
instanceId: 'some-id',
|
|
environment: 'some-env',
|
|
bucket: {
|
|
start: Date.now(),
|
|
stop: Date.now(),
|
|
toggles: {
|
|
someToggle: {
|
|
yes: 52,
|
|
no: 2,
|
|
variants: {},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
expect(
|
|
validateSchema('#/components/schemas/clientMetricsSchema', data),
|
|
).toBeUndefined();
|
|
});
|
|
|
|
test('clientMetricsSchema should ignore additional properties without failing when required fields are there', () => {
|
|
expect(
|
|
validateSchema('#/components/schemas/clientMetricsSchema', {
|
|
appName: 'a',
|
|
someParam: 'some-value',
|
|
bucket: {
|
|
start: Date.now(),
|
|
stop: Date.now(),
|
|
toggles: {
|
|
someToggle: {
|
|
yes: 52,
|
|
variants: {},
|
|
someOtherParam: 'some-other-value',
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
).toBeUndefined();
|
|
});
|
|
|
|
test('clientMetricsSchema should fail when required field is missing', () => {
|
|
expect(
|
|
validateSchema('#/components/schemas/clientMetricsSchema', {
|
|
appName: 'a',
|
|
bucket: {
|
|
start: Date.now(),
|
|
toggles: {
|
|
someToggle: {
|
|
yes: 52,
|
|
variants: {},
|
|
someOtherParam: 'some-other-value',
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
).toMatchSnapshot();
|
|
});
|