Skip to content

Commit aee2631

Browse files
Reuse FF mocks
1 parent c25731b commit aee2631

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

src/evaluator/matchers/__tests__/dependency.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { IMatcher, IMatcherDto } from '../../types';
55
import { IStorageSync } from '../../../storages/types';
66
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
77
import { ISplit } from '../../../dtos/types';
8-
9-
const ALWAYS_ON_SPLIT = { 'trafficTypeName': 'user', 'name': 'always-on', 'trafficAllocation': 100, 'trafficAllocationSeed': 1012950810, 'seed': -725161385, 'status': 'ACTIVE', 'killed': false, 'defaultTreatment': 'off', 'changeNumber': 1494364996459, 'algo': 2, 'conditions': [{ 'conditionType': 'ROLLOUT', 'matcherGroup': { 'combiner': 'AND', 'matchers': [{ 'keySelector': { 'trafficType': 'user', 'attribute': null }, 'matcherType': 'ALL_KEYS', 'negate': false, 'userDefinedSegmentMatcherData': null, 'whitelistMatcherData': null, 'unaryNumericMatcherData': null, 'betweenMatcherData': null }] }, 'partitions': [{ 'treatment': 'on', 'size': 100 }, { 'treatment': 'off', 'size': 0 }], 'label': 'in segment all' }], 'sets':[] } as ISplit;
10-
const ALWAYS_OFF_SPLIT = { 'trafficTypeName': 'user', 'name': 'always-off', 'trafficAllocation': 100, 'trafficAllocationSeed': -331690370, 'seed': 403891040, 'status': 'ACTIVE', 'killed': false, 'defaultTreatment': 'on', 'changeNumber': 1494365020316, 'algo': 2, 'conditions': [{ 'conditionType': 'ROLLOUT', 'matcherGroup': { 'combiner': 'AND', 'matchers': [{ 'keySelector': { 'trafficType': 'user', 'attribute': null }, 'matcherType': 'ALL_KEYS', 'negate': false, 'userDefinedSegmentMatcherData': null, 'whitelistMatcherData': null, 'unaryNumericMatcherData': null, 'betweenMatcherData': null }] }, 'partitions': [{ 'treatment': 'on', 'size': 0 }, { 'treatment': 'off', 'size': 100 }], 'label': 'in segment all' }], 'sets':[] } as ISplit;
8+
import { ALWAYS_ON_SPLIT, ALWAYS_OFF_SPLIT } from '../../../storages/__tests__/testUtils';
119

1210
const STORED_SPLITS: Record<string, ISplit> = {
1311
'always-on': ALWAYS_ON_SPLIT,

src/evaluator/matchers/__tests__/rbsegment.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
66
import { IRBSegment, ISplit } from '../../../dtos/types';
77
import { IStorageAsync, IStorageSync } from '../../../storages/types';
88
import { thenable } from '../../../utils/promise/thenable';
9-
10-
const ALWAYS_ON_SPLIT = { 'trafficTypeName': 'user', 'name': 'always-on', 'trafficAllocation': 100, 'trafficAllocationSeed': 1012950810, 'seed': -725161385, 'status': 'ACTIVE', 'killed': false, 'defaultTreatment': 'off', 'changeNumber': 1494364996459, 'algo': 2, 'conditions': [{ 'conditionType': 'ROLLOUT', 'matcherGroup': { 'combiner': 'AND', 'matchers': [{ 'keySelector': { 'trafficType': 'user', 'attribute': null }, 'matcherType': 'ALL_KEYS', 'negate': false, 'userDefinedSegmentMatcherData': null, 'whitelistMatcherData': null, 'unaryNumericMatcherData': null, 'betweenMatcherData': null }] }, 'partitions': [{ 'treatment': 'on', 'size': 100 }, { 'treatment': 'off', 'size': 0 }], 'label': 'in segment all' }], 'sets': [] } as ISplit;
9+
import { ALWAYS_ON_SPLIT } from '../../../storages/__tests__/testUtils';
1110

1211
const STORED_SPLITS: Record<string, ISplit> = {
1312
'always-on': ALWAYS_ON_SPLIT

src/storages/__tests__/testUtils.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@ export function assertSyncRecorderCacheInterface(cache: IEventsCacheSync | IImpr
2222

2323
// Split mocks
2424

25-
//@ts-ignore
26-
export const splitWithUserTT: ISplit = { name: 'user_ff', trafficTypeName: 'user_tt', conditions: [] };
27-
//@ts-ignore
28-
export const splitWithAccountTT: ISplit = { name: 'account_ff', trafficTypeName: 'account_tt', conditions: [] };
29-
//@ts-ignore
30-
export const splitWithAccountTTAndUsesSegments: ISplit = { trafficTypeName: 'account_tt', conditions: [{ matcherGroup: { matchers: [{ matcherType: 'IN_SEGMENT', userDefinedSegmentMatcherData: { segmentName: 'employees' } }] } }] };
31-
//@ts-ignore
32-
export const something: ISplit = { name: 'something' };
33-
//@ts-ignore
25+
26+
export const ALWAYS_ON_SPLIT: ISplit = { 'trafficTypeName': 'user', 'name': 'always-on', 'trafficAllocation': 100, 'trafficAllocationSeed': 1012950810, 'seed': -725161385, 'status': 'ACTIVE', 'killed': false, 'defaultTreatment': 'off', 'changeNumber': 1494364996459, 'conditions': [{ 'conditionType': 'ROLLOUT', 'matcherGroup': { 'combiner': 'AND', 'matchers': [{ 'keySelector': { 'trafficType': 'user', 'attribute': null }, 'matcherType': 'ALL_KEYS', 'negate': false, 'userDefinedSegmentMatcherData': null, 'whitelistMatcherData': null, 'unaryNumericMatcherData': null, 'betweenMatcherData': null }] }, 'partitions': [{ 'treatment': 'on', 'size': 100 }, { 'treatment': 'off', 'size': 0 }], 'label': 'in segment all' }], 'sets': [] };
27+
export const ALWAYS_OFF_SPLIT: ISplit = { 'trafficTypeName': 'user', 'name': 'always-off', 'trafficAllocation': 100, 'trafficAllocationSeed': -331690370, 'seed': 403891040, 'status': 'ACTIVE', 'killed': false, 'defaultTreatment': 'on', 'changeNumber': 1494365020316, 'conditions': [{ 'conditionType': 'ROLLOUT', 'matcherGroup': { 'combiner': 'AND', 'matchers': [{ 'keySelector': { 'trafficType': 'user', 'attribute': null }, 'matcherType': 'ALL_KEYS', 'negate': false, 'userDefinedSegmentMatcherData': null, 'whitelistMatcherData': null, 'unaryNumericMatcherData': null, 'betweenMatcherData': null }] }, 'partitions': [{ 'treatment': 'on', 'size': 0 }, { 'treatment': 'off', 'size': 100 }], 'label': 'in segment all' }], 'sets': [] }; //@ts-ignore
28+
export const splitWithUserTT: ISplit = { name: 'user_ff', trafficTypeName: 'user_tt', conditions: [] }; //@ts-ignore
29+
export const splitWithAccountTT: ISplit = { name: 'account_ff', trafficTypeName: 'account_tt', conditions: [] }; //@ts-ignore
30+
export const splitWithAccountTTAndUsesSegments: ISplit = { trafficTypeName: 'account_tt', conditions: [{ matcherGroup: { matchers: [{ matcherType: 'IN_SEGMENT', userDefinedSegmentMatcherData: { segmentName: 'employees' } }] } }] }; //@ts-ignore
31+
export const something: ISplit = { name: 'something' }; //@ts-ignore
3432
export const somethingElse: ISplit = { name: 'something else' };
3533

3634
// - With flag sets
3735

3836
//@ts-ignore
3937
export const featureFlagWithEmptyFS: ISplit = { name: 'ff_empty', sets: [] };
4038
//@ts-ignore
41-
export const featureFlagOne: ISplit = { name: 'ff_one', sets: ['o','n','e'] };
39+
export const featureFlagOne: ISplit = { name: 'ff_one', sets: ['o', 'n', 'e'] };
4240
//@ts-ignore
43-
export const featureFlagTwo: ISplit = { name: 'ff_two', sets: ['t','w','o'] };
41+
export const featureFlagTwo: ISplit = { name: 'ff_two', sets: ['t', 'w', 'o'] };
4442
//@ts-ignore
45-
export const featureFlagThree: ISplit = { name: 'ff_three', sets: ['t','h','r','e'] };
43+
export const featureFlagThree: ISplit = { name: 'ff_three', sets: ['t', 'h', 'r', 'e'] };
4644
//@ts-ignore
4745
export const featureFlagWithoutFS: ISplit = { name: 'ff_four' };
4846

0 commit comments

Comments
 (0)