@@ -13,18 +13,26 @@ 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 ,
23
27
name : 'mauro_rule_based_segment' ,
24
28
status : 'ACTIVE' ,
25
29
excluded : {
26
30
keys : [ 'mauro@split.io' , 'gaston@split.io' ] ,
27
- 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
+ ]
28
36
} ,
29
37
conditions : [
30
38
{
@@ -135,6 +143,31 @@ const STORED_RBSEGMENTS: Record<string, IRBSegment> = {
135
143
}
136
144
} ]
137
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
+ }
138
171
} ;
139
172
140
173
const mockStorageSync = {
@@ -149,6 +182,11 @@ const mockStorageSync = {
149
182
return STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
150
183
}
151
184
} ,
185
+ largeSegments : {
186
+ isInSegment ( segmentName : string , matchingKey : string ) {
187
+ return STORED_LARGE_SEGMENTS [ segmentName ] ? STORED_LARGE_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ;
188
+ }
189
+ } ,
152
190
rbSegments : {
153
191
get ( rbsegmentName : string ) {
154
192
return STORED_RBSEGMENTS [ rbsegmentName ] ;
@@ -168,6 +206,11 @@ const mockStorageAsync = {
168
206
return Promise . resolve ( STORED_SEGMENTS [ segmentName ] ? STORED_SEGMENTS [ segmentName ] . has ( matchingKey ) : false ) ;
169
207
}
170
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
+ } ,
171
214
rbSegments : {
172
215
get ( rbsegmentName : string ) {
173
216
return Promise . resolve ( STORED_RBSEGMENTS [ rbsegmentName ] ) ;
@@ -190,18 +233,28 @@ describe.each([
190
233
value : 'depend_on_mauro_rule_based_segment'
191
234
} as IMatcherDto , mockStorage ) ! ;
192
235
193
- [ matcher , dependentMatcher ] . forEach ( async matcher => {
236
+ [ matcher , dependentMatcher ] . forEach ( async ( matcher ) => {
194
237
195
238
// should return false if the provided key is excluded (even if some condition is met)
196
239
let match = matcher ( { key : 'mauro@split.io' , attributes : { location : 'mdp' } } , evaluateFeature ) ;
197
240
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
198
241
expect ( await match ) . toBe ( false ) ;
199
242
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)
201
244
match = matcher ( { key : 'emi@split.io' , attributes : { location : 'tandil' } } , evaluateFeature ) ;
202
245
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
203
246
expect ( await match ) . toBe ( false ) ;
204
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
+
205
258
// should return false if doesn't match any condition
206
259
match = matcher ( { key : 'zeta@split.io' } , evaluateFeature ) ;
207
260
expect ( thenable ( match ) ) . toBe ( isAsync ) ;
0 commit comments