@@ -13,10 +13,14 @@ const STORED_SPLITS: Record<string, ISplit> = {
13
13
} ;
14
14
15
15
const STORED_SEGMENTS : Record < string , Set < string > > = {
16
- 'segment_test ' : new Set ( [ 'emi@split.io' ] ) ,
16
+ 'excluded_standard_segment ' : new Set ( [ 'emi@split.io' ] ) ,
17
17
'regular_segment' : new Set ( [ 'nadia@split.io' ] )
18
18
} ;
19
19
20
+ const STORED_LARGE_SEGMENTS : Record < string , Set < string > > = {
21
+ 'excluded_large_segment' : new Set ( [ 'emi-large@split.io' ] )
22
+ } ;
23
+
20
24
const STORED_RBSEGMENTS : Record < string , IRBSegment > = {
21
25
'mauro_rule_based_segment' : {
22
26
changeNumber : 5 ,
@@ -25,7 +29,9 @@ const STORED_RBSEGMENTS: Record<string, IRBSegment> = {
25
29
excluded : {
26
30
keys : [ 'mauro@split.io' , 'gaston@split.io' ] ,
27
31
segments : [
28
- { type : 'regular' , name : 'segment_test' }
32
+ { type : 'standard' , name : 'excluded_standard_segment' } ,
33
+ { type : 'large' , name : 'excluded_large_segment' } ,
34
+ { type : 'rule-based' , name : 'excluded_rule_based_segment' }
29
35
]
30
36
} ,
31
37
conditions : [
@@ -137,6 +143,31 @@ const STORED_RBSEGMENTS: Record<string, IRBSegment> = {
137
143
}
138
144
} ]
139
145
} ,
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
+ whitelist : [ 'emi-rule-based@split.io' ]
162
+ } ,
163
+ unaryNumericMatcherData : null ,
164
+ betweenMatcherData : null
165
+ }
166
+ ]
167
+ }
168
+ }
169
+ ] ,
170
+ }
140
171
} ;
141
172
142
173
const mockStorageSync = {
@@ -151,6 +182,11 @@ const mockStorageSync = {
151
182
return STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
152
183
}
153
184
} ,
185
+ largeSegments : {
186
+ isInSegment ( segmentName : string , matchingKey : string ) {
187
+ return STORED_LARGE_SEGMENTS [ segmentName ] ? STORED_LARGE_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
188
+ }
189
+ } ,
154
190
rbSegments : {
155
191
get ( rbsegmentName : string ) {
156
192
return STORED_RBSEGMENTS [ rbsegmentName ] ;
@@ -170,6 +206,11 @@ const mockStorageAsync = {
170
206
return Promise . resolve ( STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ) ;
171
207
}
172
208
} ,
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
+ } ,
173
214
rbSegments : {
174
215
get ( rbsegmentName : string ) {
175
216
return Promise . resolve ( STORED_RBSEGMENTS [ rbsegmentName ] ) ;
@@ -192,18 +233,28 @@ describe.each([
192
233
value : 'depend_on_mauro_rule_based_segment'
193
234
} as IMatcherDto , mockStorage ) ! ;
194
235
195
- [ matcher , dependentMatcher ] . forEach ( async matcher => {
236
+ [ matcher , dependentMatcher ] . forEach ( async ( matcher ) => {
196
237
197
238
// should return false if the provided key is excluded (even if some condition is met)
198
239
let match = matcher ( { key : 'mauro@split.io' , attributes : { location : 'mdp' } } , evaluateFeature ) ;
199
240
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
200
241
expect ( await match ) . toBe ( false ) ;
201
242
202
- // 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)
203
244
match = matcher ( { key : 'emi@split.io' , attributes : { location : 'tandil' } } , evaluateFeature ) ;
204
245
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
205
246
expect ( await match ) . toBe ( false ) ;
206
247
248
+ // should return false if the provided key is in some excluded large segment (even if some condition is met)
249
+ match = matcher ( { key : 'emi-large@split.io' , 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 : 'emi-rule-based@split.io' , attributes : { location : 'tandil' } } , evaluateFeature ) ;
255
+ expect ( thenable ( match ) ) . toBe ( isAsync ) ;
256
+ expect ( await match ) . toBe ( false ) ;
257
+
207
258
// should return false if doesn't match any condition
208
259
match = matcher ( { key : 'zeta@split.io' } , evaluateFeature ) ;
209
260
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
0 commit comments