Skip to content

Commit d23979b

Browse files
authored
chore(tests): Minor test cleanup (#78)
1 parent 0f6cfdb commit d23979b

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/client/eppo-client.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ describe('EppoClient E2E test', () => {
233233
assignments = getTestAssignments(
234234
{ flag, variationType, defaultValue, subjects },
235235
assignmentFn,
236-
false,
237236
);
238237

239238
validateTestAssignments(assignments, flag);
@@ -280,7 +279,6 @@ describe('EppoClient E2E test', () => {
280279
const assignments = getTestAssignments(
281280
{ flag, variationType, defaultValue, subjects },
282281
assignmentFn,
283-
true,
284282
);
285283

286284
validateTestAssignments(assignments, flag);

test/testHelpers.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ export const ASSIGNMENT_TEST_DATA_DIR = TEST_DATA_DIR + 'tests/';
88
const MOCK_UFC_FILENAME = 'flags-v1';
99
export const MOCK_UFC_RESPONSE_FILE = `${MOCK_UFC_FILENAME}.json`;
1010
export const OBFUSCATED_MOCK_UFC_RESPONSE_FILE = `${MOCK_UFC_FILENAME}-obfuscated.json`;
11-
12-
export enum ValueTestType {
13-
BoolType = 'boolean',
14-
NumericType = 'numeric',
15-
StringType = 'string',
16-
JSONType = 'json',
17-
}
18-
1911
export interface SubjectTestCase {
2012
subjectKey: string;
2113
subjectAttributes: Record<string, AttributeType>;
@@ -36,20 +28,19 @@ export function readMockUFCResponse(filename: string): {
3628
}
3729

3830
export function readAssignmentTestData(): IAssignmentTestCase[] {
39-
const testCaseData: IAssignmentTestCase[] = [];
40-
const testCaseFiles = fs.readdirSync(ASSIGNMENT_TEST_DATA_DIR);
41-
testCaseFiles.forEach((file) => {
42-
const testCase = JSON.parse(fs.readFileSync(ASSIGNMENT_TEST_DATA_DIR + file, 'utf8'));
43-
testCaseData.push(testCase);
44-
});
45-
return testCaseData;
31+
return fs
32+
.readdirSync(ASSIGNMENT_TEST_DATA_DIR)
33+
.map((file) => JSON.parse(fs.readFileSync(ASSIGNMENT_TEST_DATA_DIR + file, 'utf8')));
4634
}
4735

4836
export function getTestAssignments(
4937
testCase: IAssignmentTestCase,
50-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
51-
assignmentFn: any,
52-
obfuscated = false,
38+
assignmentFn: (
39+
flagKey: string,
40+
subjectKey: string,
41+
subjectAttributes: Record<string, AttributeType>,
42+
defaultValue: string | number | boolean | object,
43+
) => never,
5344
): { subject: SubjectTestCase; assignment: string | boolean | number | null | object }[] {
5445
const assignments: {
5546
subject: SubjectTestCase;
@@ -61,9 +52,8 @@ export function getTestAssignments(
6152
subject.subjectKey,
6253
subject.subjectAttributes,
6354
testCase.defaultValue,
64-
obfuscated,
6555
);
66-
assignments.push({ subject: subject, assignment: assignment });
56+
assignments.push({ subject, assignment });
6757
}
6858
return assignments;
6959
}

0 commit comments

Comments
 (0)