Skip to content

Commit ea68f15

Browse files
Polish tests
1 parent 7e805ce commit ea68f15

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/sdkClient/__tests__/clientInputValidation.spec.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,28 @@ describe('clientInputValidationDecorator', () => {
2828
expect(clientWithValidation.getTreatment('key')).toEqual('control');
2929
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatment: you passed a null or undefined feature flag name. It must be a non-empty string.');
3030

31-
expect(clientWithValidation.getTreatmentsWithConfig('key')).toEqual({});
31+
expect(clientWithValidation.getTreatmentWithConfig('key', [])).toEqual({ treatment: 'control', config: null });
32+
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatmentWithConfig: you passed an invalid feature flag name. It must be a non-empty string.');
33+
34+
expect(clientWithValidation.getTreatments('key')).toEqual({});
35+
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatments: feature flag names must be a non-empty array.');
36+
37+
expect(clientWithValidation.getTreatmentsWithConfig('key', [])).toEqual({});
3238
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatmentsWithConfig: feature flag names must be a non-empty array.');
3339

34-
// @TODO fix log error message for getTreatmentsByFlagSet
35-
// expect(clientWithValidation.getTreatmentsByFlagSet('key')).toEqual({});
36-
// expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatmentsByFlagSet: you passed a null or undefined flag set name. It must be a non-empty string.');
40+
expect(clientWithValidation.getTreatmentsByFlagSet('key')).toEqual({});
41+
expect(logSpy).toBeCalledWith('[ERROR] splitio => getTreatmentsByFlagSet: you passed a null or undefined flag set. It must be a non-empty string.');
42+
43+
expect(clientWithValidation.getTreatmentsWithConfigByFlagSet('key', [])).toEqual({});
44+
expect(logSpy).toBeCalledWith('[ERROR] splitio => getTreatmentsWithConfigByFlagSet: you passed an invalid flag set. It must be a non-empty string.');
3745

38-
expect(clientWithValidation.getTreatmentsWithConfigByFlagSets('key')).toEqual({});
46+
expect(clientWithValidation.getTreatmentsByFlagSets('key')).toEqual({});
47+
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatmentsByFlagSets: flag sets must be a non-empty array.');
48+
49+
expect(clientWithValidation.getTreatmentsWithConfigByFlagSets('key', [])).toEqual({});
3950
expect(logSpy).toHaveBeenLastCalledWith('[ERROR] splitio => getTreatmentsWithConfigByFlagSets: flag sets must be a non-empty array.');
51+
52+
// @TODO should be 8, but there is an additional log from `getTreatmentsByFlagSet` and `getTreatmentsWithConfigByFlagSet` that should be removed
53+
expect(logSpy).toBeCalledTimes(10);
4054
});
4155
});

0 commit comments

Comments
 (0)