@@ -13,18 +13,26 @@ const STORED_SPLITS: Record<string, ISplit> = {
1313} ;
1414
1515const STORED_SEGMENTS : Record < string , Set < string > > = {
16- 'segment_test ' :
new Set ( [ '[email protected] ' ] ) , 16+ 'excluded_standard_segment ' :
new Set ( [ '[email protected] ' ] ) , 1717 'regular_segment' :
new Set ( [ '[email protected] ' ] ) 1818} ;
1919
20+ const STORED_LARGE_SEGMENTS : Record < string , Set < string > > = {
21+ 'excluded_large_segment' :
new Set ( [ '[email protected] ' ] ) 22+ } ;
23+
2024const STORED_RBSEGMENTS : Record < string , IRBSegment > = {
2125 'mauro_rule_based_segment' : {
2226 changeNumber : 5 ,
2327 name : 'mauro_rule_based_segment' ,
2428 status : 'ACTIVE' ,
2529 excluded : {
263027- segments : [ 'segment_test' ]
31+ segments : [
32+ { type : 'standard' , name : 'excluded_standard_segment' } ,
33+ { type : 'large' , name : 'excluded_large_segment' } ,
34+ { type : 'rule-based' , name : 'excluded_rule_based_segment' }
35+ ]
2836 } ,
2937 conditions : [
3038 {
@@ -135,6 +143,31 @@ const STORED_RBSEGMENTS: Record<string, IRBSegment> = {
135143 }
136144 } ]
137145 } ,
146+ 'excluded_rule_based_segment' : {
147+ name : 'excluded_rule_based_segment' ,
148+ changeNumber : 123 ,
149+ status : 'ACTIVE' ,
150+ conditions : [
151+ {
152+ matcherGroup : {
153+ combiner : 'AND' ,
154+ matchers : [
155+ {
156+ keySelector : null ,
157+ matcherType : 'WHITELIST' ,
158+ negate : false ,
159+ userDefinedSegmentMatcherData : null ,
160+ whitelistMatcherData : {
161+ 162+ } ,
163+ unaryNumericMatcherData : null ,
164+ betweenMatcherData : null
165+ }
166+ ]
167+ }
168+ }
169+ ] ,
170+ }
138171} ;
139172
140173const mockStorageSync = {
@@ -149,6 +182,11 @@ const mockStorageSync = {
149182 return STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
150183 }
151184 } ,
185+ largeSegments : {
186+ isInSegment ( segmentName : string , matchingKey : string ) {
187+ return STORED_LARGE_SEGMENTS [ segmentName ] ? STORED_LARGE_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
188+ }
189+ } ,
152190 rbSegments : {
153191 get ( rbsegmentName : string ) {
154192 return STORED_RBSEGMENTS [ rbsegmentName ] ;
@@ -168,6 +206,11 @@ const mockStorageAsync = {
168206 return Promise . resolve ( STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ) ;
169207 }
170208 } ,
209+ largeSegments : {
210+ isInSegment ( segmentName : string , matchingKey : string ) {
211+ return Promise . resolve ( STORED_LARGE_SEGMENTS [ segmentName ] ? STORED_LARGE_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ) ;
212+ }
213+ } ,
171214 rbSegments : {
172215 get ( rbsegmentName : string ) {
173216 return Promise . resolve ( STORED_RBSEGMENTS [ rbsegmentName ] ) ;
@@ -190,18 +233,28 @@ describe.each([
190233 value : 'depend_on_mauro_rule_based_segment'
191234 } as IMatcherDto , mockStorage ) ! ;
192235
193- [ matcher , dependentMatcher ] . forEach ( async matcher => {
236+ [ matcher , dependentMatcher ] . forEach ( async ( matcher ) => {
194237
195238 // should return false if the provided key is excluded (even if some condition is met)
196239 let match = matcher ( { key :
'[email protected] ' , attributes :
{ location :
'mdp' } } , evaluateFeature ) ; 197240 expect ( thenable ( match ) ) . toBe ( isAsync ) ;
198241 expect ( await match ) . toBe ( false ) ;
199242
200- // should return false if the provided key is in some excluded segment (even if some condition is met)
243+ // should return false if the provided key is in some excluded standard segment (even if some condition is met)
201244 match = matcher ( { key :
'[email protected] ' , attributes :
{ location :
'tandil' } } , evaluateFeature ) ; 202245 expect ( thenable ( match ) ) . toBe ( isAsync ) ;
203246 expect ( await match ) . toBe ( false ) ;
204247
248+ // should return false if the provided key is in some excluded large segment (even if some condition is met)
249+ match = matcher ( { key :
'[email protected] ' , attributes :
{ location :
'tandil' } } , evaluateFeature ) ; 250+ expect ( thenable ( match ) ) . toBe ( isAsync ) ;
251+ expect ( await match ) . toBe ( false ) ;
252+
253+ // should return false if the provided key is in some excluded rule-based segment (even if some condition is met)
254+ match = matcher ( { key :
'[email protected] ' , attributes :
{ location :
'tandil' } } , evaluateFeature ) ; 255+ expect ( thenable ( match ) ) . toBe ( isAsync ) ;
256+ expect ( await match ) . toBe ( false ) ;
257+
205258 // should return false if doesn't match any condition
206259 match = matcher ( { key :
'[email protected] ' } , evaluateFeature ) ; 207260 expect ( thenable ( match ) ) . toBe ( isAsync ) ;
0 commit comments