Skip to content

Commit ea66074

Browse files
Fix tests
1 parent a2d4615 commit ea66074

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v4
2323

2424
- name: Set up nodejs
25-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v4
2626
with:
2727
node-version: 'lts/*'
2828
cache: 'npm'

src/storages/__tests__/KeyBuilder.spec.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,22 @@ test('KEYS / latency and exception keys (telemetry)', () => {
105105

106106
test('getStorageHash', () => {
107107
expect(getStorageHash({
108-
core: { authorizationKey: '<fake-token-rfc>' },
108+
core: { authorizationKey: 'sdk-key' },
109109
sync: { __splitFiltersValidation: { queryString: '&names=p1__split,p2__split' }, flagSpecVersion: '1.3' }
110-
} as ISettings)).toBe('2ce5cc38');
110+
} as ISettings)).toBe('d700da23');
111111

112112
expect(getStorageHash({
113-
core: { authorizationKey: '<fake-token-rfc>' },
113+
core: { authorizationKey: 'sdk-key' },
114114
sync: { __splitFiltersValidation: { queryString: '&names=p2__split,p3__split' }, flagSpecVersion: '1.3' }
115-
} as ISettings)).toBe('e65079c6');
115+
} as ISettings)).toBe('8c8a8789');
116116

117117
expect(getStorageHash({
118-
core: { authorizationKey: '<fake-token-rfc>' },
118+
core: { authorizationKey: 'aaaabbbbcccc1234' },
119119
sync: { __splitFiltersValidation: { queryString: null }, flagSpecVersion: '1.3' }
120-
} as ISettings)).toBe('193e6f3f');
120+
} as ISettings)).toBe('dc1f9817');
121+
122+
expect(getStorageHash({
123+
core: { authorizationKey: 'another-sdk-key' },
124+
sync: { __splitFiltersValidation: { queryString: null }, flagSpecVersion: '1.3' }
125+
} as ISettings)).toBe('45c6ba5d');
121126
});

src/storages/inLocalStorage/__tests__/validateCache.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SplitsCacheInLocal } from '../SplitsCacheInLocal';
66
import { nearlyEqual } from '../../../__tests__/testUtils';
77
import { MySegmentsCacheInLocal } from '../MySegmentsCacheInLocal';
88

9-
const FULL_SETTINGS_HASH = '404832b3';
9+
const FULL_SETTINGS_HASH = 'dc1f9817';
1010

1111
describe('validateCache', () => {
1212
const keys = new KeyBuilderCS('SPLITIO', 'user');
@@ -77,15 +77,15 @@ describe('validateCache', () => {
7777
localStorage.setItem(keys.buildSplitsTillKey(), '1');
7878
localStorage.setItem(keys.buildHashKey(), FULL_SETTINGS_HASH);
7979

80-
expect(validateCache({}, { ...fullSettings, core: { ...fullSettings.core, authorizationKey: 'another' } }, keys, splits, segments, largeSegments)).toBe(false);
80+
expect(validateCache({}, { ...fullSettings, core: { ...fullSettings.core, authorizationKey: 'another-sdk-key' } }, keys, splits, segments, largeSegments)).toBe(false);
8181

8282
expect(logSpy).toHaveBeenCalledWith('storage:localstorage: SDK key, flags filter criteria, or flags spec version has changed. Cleaning up cache');
8383

8484
expect(splits.clear).toHaveBeenCalledTimes(1);
8585
expect(segments.clear).toHaveBeenCalledTimes(1);
8686
expect(largeSegments.clear).toHaveBeenCalledTimes(1);
8787

88-
expect(localStorage.getItem(keys.buildHashKey())).toBe('aa4877c2');
88+
expect(localStorage.getItem(keys.buildHashKey())).toBe('45c6ba5d');
8989
expect(nearlyEqual(parseInt(localStorage.getItem(keys.buildLastClear()) as string), Date.now())).toBe(true);
9090
});
9191

src/utils/settingsValidation/__tests__/settings.mocks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
22
import { ISettings } from '../../../types';
33
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
4+
import { FLAG_SPEC_VERSION } from '../../constants';
45

56
export const settingsWithKey = {
67
core: {
@@ -67,7 +68,7 @@ export const fullSettings: ISettings = {
6768
groupedFilters: { bySet: [], byName: [], byPrefix: [] },
6869
},
6970
enabled: true,
70-
flagSpecVersion: '1.3'
71+
flagSpecVersion: FLAG_SPEC_VERSION
7172
},
7273
version: 'jest',
7374
runtime: {

0 commit comments

Comments
 (0)