@@ -163,7 +163,7 @@ test('SPLIT CACHE / LocalStorage / usesSegments', () => {
163163 expect ( cache . usesSegments ( ) ) . toBe ( false ) ; // 0 splits using segments
164164} ) ;
165165
166- test ( 'SPLIT CACHE / LocalStorage / flag set cache tests ' , ( ) => {
166+ test ( 'SPLIT CACHE / LocalStorage / flag set cache disabled ' , ( ) => {
167167 // @ts -ignore
168168 const cache = new SplitsCacheInLocal ( {
169169 ...fullSettings ,
@@ -183,21 +183,21 @@ test('SPLIT CACHE / LocalStorage / flag set cache tests', () => {
183183 ] ) ;
184184 cache . addSplit ( featureFlagWithEmptyFS . name , featureFlagWithEmptyFS ) ;
185185
186- expect ( cache . getNamesByFlagSets ( [ 'o' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_two' ] ) ] ) ;
187- expect ( cache . getNamesByFlagSets ( [ 'n' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' ] ) ] ) ;
188- expect ( cache . getNamesByFlagSets ( [ 'e' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_three' ] ) ] ) ;
186+ expect ( cache . getNamesByFlagSets ( [ 'o' ] ) ) . toEqual ( [ emptySet ] ) ;
187+ expect ( cache . getNamesByFlagSets ( [ 'n' ] ) ) . toEqual ( [ emptySet ] ) ;
188+ expect ( cache . getNamesByFlagSets ( [ 'e' ] ) ) . toEqual ( [ emptySet ] ) ;
189189 expect ( cache . getNamesByFlagSets ( [ 't' ] ) ) . toEqual ( [ emptySet ] ) ; // 't' not in filter
190- expect ( cache . getNamesByFlagSets ( [ 'o' , 'n' , 'e' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_two' ] ) , new _Set ( [ 'ff_one' ] ) , new _Set ( [ 'ff_one' , 'ff_three' ] ) ] ) ;
190+ expect ( cache . getNamesByFlagSets ( [ 'o' , 'n' , 'e' ] ) ) . toEqual ( [ emptySet , emptySet , emptySet ] ) ;
191191
192192 cache . addSplit ( featureFlagOne . name , { ...featureFlagOne , sets : [ '1' ] } ) ;
193193
194194 expect ( cache . getNamesByFlagSets ( [ '1' ] ) ) . toEqual ( [ emptySet ] ) ; // '1' not in filter
195- expect ( cache . getNamesByFlagSets ( [ 'o' ] ) ) . toEqual ( [ new _Set ( [ 'ff_two' ] ) ] ) ;
195+ expect ( cache . getNamesByFlagSets ( [ 'o' ] ) ) . toEqual ( [ emptySet ] ) ;
196196 expect ( cache . getNamesByFlagSets ( [ 'n' ] ) ) . toEqual ( [ emptySet ] ) ;
197197
198198 cache . addSplit ( featureFlagOne . name , { ...featureFlagOne , sets : [ 'x' ] } ) ;
199- expect ( cache . getNamesByFlagSets ( [ 'x' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' ] ) ] ) ;
200- expect ( cache . getNamesByFlagSets ( [ 'o' , 'e' , 'x' ] ) ) . toEqual ( [ new _Set ( [ 'ff_two' ] ) , new _Set ( [ 'ff_three' ] ) , new _Set ( [ 'ff_one' ] ) ] ) ;
199+ expect ( cache . getNamesByFlagSets ( [ 'x' ] ) ) . toEqual ( [ emptySet ] ) ;
200+ expect ( cache . getNamesByFlagSets ( [ 'o' , 'e' , 'x' ] ) ) . toEqual ( [ emptySet , emptySet , emptySet ] ) ;
201201
202202
203203 cache . removeSplit ( featureFlagOne . name ) ;
@@ -211,27 +211,27 @@ test('SPLIT CACHE / LocalStorage / flag set cache tests', () => {
211211 expect ( cache . getNamesByFlagSets ( [ ] ) ) . toEqual ( [ ] ) ;
212212} ) ;
213213
214- // if FlagSets are not defined, it should store all FlagSets in memory.
215- test ( 'SPLIT CACHE / LocalStorage / flag set cache tests without filters' , ( ) => {
216- const cacheWithoutFilters = new SplitsCacheInLocal ( fullSettings , new KeyBuilderCS ( 'SPLITIO' , 'user' ) ) ;
217- const emptySet = new _Set ( [ ] ) ;
218-
219- cacheWithoutFilters . addSplits ( [
220- [ featureFlagOne . name , featureFlagOne ] ,
221- [ featureFlagTwo . name , featureFlagTwo ] ,
222- [ featureFlagThree . name , featureFlagThree ] ,
223- ] ) ;
224- cacheWithoutFilters . addSplit ( featureFlagWithEmptyFS . name , featureFlagWithEmptyFS ) ;
225-
226- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 'o' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_two' ] ) ] ) ;
227- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 'n' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' ] ) ] ) ;
228- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 'e' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_three' ] ) ] ) ;
229- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 't' ] ) ) . toEqual ( [ new _Set ( [ 'ff_two' , 'ff_three' ] ) ] ) ;
230- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 'y' ] ) ) . toEqual ( [ emptySet ] ) ;
231- expect ( cacheWithoutFilters . getNamesByFlagSets ( [ 'o' , 'n' , 'e' ] ) ) . toEqual ( [ new _Set ( [ 'ff_one' , 'ff_two' ] ) , new _Set ( [ 'ff_one' ] ) , new _Set ( [ 'ff_one' , 'ff_three' ] ) ] ) ;
232-
233- // Validate that the feature flag cache is cleared when calling `clear` method
234- cacheWithoutFilters . clear ( ) ;
235- expect ( localStorage . length ) . toBe ( 1 ) ; // only 'SPLITIO.hash' should remain in localStorage
236- expect ( localStorage . key ( 0 ) ) . toBe ( 'SPLITIO.hash' ) ;
237- } ) ;
214+ // // if FlagSets are not defined, it should store all FlagSets in memory.
215+ // test('SPLIT CACHE / LocalStorage / flag set cache tests without filters', () => {
216+ // const cacheWithoutFilters = new SplitsCacheInLocal(fullSettings, new KeyBuilderCS('SPLITIO', 'user'));
217+ // const emptySet = new _Set([]);
218+
219+ // cacheWithoutFilters.addSplits([
220+ // [featureFlagOne.name, featureFlagOne],
221+ // [featureFlagTwo.name, featureFlagTwo],
222+ // [featureFlagThree.name, featureFlagThree],
223+ // ]);
224+ // cacheWithoutFilters.addSplit(featureFlagWithEmptyFS.name, featureFlagWithEmptyFS);
225+
226+ // expect(cacheWithoutFilters.getNamesByFlagSets(['o'])).toEqual([new _Set(['ff_one', 'ff_two'])]);
227+ // expect(cacheWithoutFilters.getNamesByFlagSets(['n'])).toEqual([new _Set(['ff_one'])]);
228+ // expect(cacheWithoutFilters.getNamesByFlagSets(['e'])).toEqual([new _Set(['ff_one', 'ff_three'])]);
229+ // expect(cacheWithoutFilters.getNamesByFlagSets(['t'])).toEqual([new _Set(['ff_two', 'ff_three'])]);
230+ // expect(cacheWithoutFilters.getNamesByFlagSets(['y'])).toEqual([emptySet]);
231+ // expect(cacheWithoutFilters.getNamesByFlagSets(['o', 'n', 'e'])).toEqual([new _Set(['ff_one', 'ff_two']), new _Set(['ff_one']), new _Set(['ff_one', 'ff_three'])]);
232+
233+ // // Validate that the feature flag cache is cleared when calling `clear` method
234+ // cacheWithoutFilters.clear();
235+ // expect(localStorage.length).toBe(1); // only 'SPLITIO.hash' should remain in localStorage
236+ // expect(localStorage.key(0)).toBe('SPLITIO.hash');
237+ // });
0 commit comments