-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtestUtils.ts
More file actions
25 lines (20 loc) · 1.03 KB
/
testUtils.ts
File metadata and controls
25 lines (20 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const clientApiMethods = ['getTreatment', 'getTreatments', 'getTreatmentWithConfig', 'getTreatmentsWithConfig', 'getTreatmentsByFlagSets', 'getTreatmentsWithConfigByFlagSets', 'getTreatmentsByFlagSet', 'getTreatmentsWithConfigByFlagSet', 'track', 'destroy'];
export function assertClientApi(client: any, sdkStatus?: object) {
if (sdkStatus) expect(Object.getPrototypeOf(client)).toBe(sdkStatus);
clientApiMethods.forEach(method => {
expect(typeof client[method]).toBe('function');
});
}
export function createClientMock(returnValue: any) {
return {
getTreatment: jest.fn(()=> returnValue),
getTreatmentWithConfig: jest.fn(()=> returnValue),
getTreatments: jest.fn(()=> returnValue),
getTreatmentsWithConfig: jest.fn(()=> returnValue),
getTreatmentsByFlagSets: jest.fn(()=> returnValue),
getTreatmentsWithConfigByFlagSets: jest.fn(()=> returnValue),
getTreatmentsByFlagSet: jest.fn(()=> returnValue),
getTreatmentsWithConfigByFlagSet: jest.fn(()=> returnValue),
track: jest.fn(()=> returnValue),
};
}