@@ -3,6 +3,8 @@ import { KeyBuilderCS } from '../../KeyBuilderCS';
33import { splitWithUserTT , splitWithAccountTT , splitWithAccountTTAndUsesSegments , something , somethingElse , featureFlagOne , featureFlagTwo , featureFlagThree , featureFlagWithEmptyFS , featureFlagWithoutFS } from '../../__tests__/testUtils' ;
44import { ISplit } from '../../../dtos/types' ;
55import { fullSettings } from '../../../utils/settingsValidation/__tests__/settings.mocks' ;
6+ import { RBSegmentsCacheInMemory } from '../../inMemory/RBSegmentsCacheInMemory' ;
7+ import { usesSegments } from '../../AbstractSplitsCacheSync' ;
68
79
810test ( 'SPLITS CACHE / LocalStorage' , ( ) => {
@@ -132,24 +134,26 @@ test('SPLITS CACHE / LocalStorage / killLocally', () => {
132134
133135test ( 'SPLITS CACHE / LocalStorage / usesSegments' , ( ) => {
134136 const cache = new SplitsCacheInLocal ( fullSettings , new KeyBuilderCS ( 'SPLITIO' , 'user' ) ) ;
137+ cache . clear ( ) ;
138+ const storage = { splits : cache , rbSegments : new RBSegmentsCacheInMemory ( ) } ;
135139
136- expect ( cache . usesSegments ( ) ) . toBe ( true ) ; // true initially, until data is synchronized
140+ expect ( usesSegments ( storage ) ) . toBe ( true ) ; // true initially, until data is synchronized
137141 cache . setChangeNumber ( 1 ) ; // to indicate that data has been synced.
138142
139143 cache . update ( [ splitWithUserTT , splitWithAccountTT ] , [ ] , 1 ) ;
140- expect ( cache . usesSegments ( ) ) . toBe ( false ) ; // 0 splits using segments
144+ expect ( usesSegments ( storage ) ) . toBe ( false ) ; // 0 splits using segments
141145
142146 cache . addSplit ( { ...splitWithAccountTTAndUsesSegments , name : 'split3' } ) ;
143- expect ( cache . usesSegments ( ) ) . toBe ( true ) ; // 1 split using segments
147+ expect ( usesSegments ( storage ) ) . toBe ( true ) ; // 1 split using segments
144148
145149 cache . addSplit ( { ...splitWithAccountTTAndUsesSegments , name : 'split4' } ) ;
146- expect ( cache . usesSegments ( ) ) . toBe ( true ) ; // 2 splits using segments
150+ expect ( usesSegments ( storage ) ) . toBe ( true ) ; // 2 splits using segments
147151
148152 cache . removeSplit ( 'split3' ) ;
149- expect ( cache . usesSegments ( ) ) . toBe ( true ) ; // 1 split using segments
153+ expect ( usesSegments ( storage ) ) . toBe ( true ) ; // 1 split using segments
150154
151155 cache . removeSplit ( 'split4' ) ;
152- expect ( cache . usesSegments ( ) ) . toBe ( false ) ; // 0 splits using segments
156+ expect ( usesSegments ( storage ) ) . toBe ( false ) ; // 0 splits using segments
153157} ) ;
154158
155159test ( 'SPLITS CACHE / LocalStorage / flag set cache tests' , ( ) => {
0 commit comments