@@ -222,11 +222,11 @@ describe('getTreatments', () => {
222
222
} ) ;
223
223
224
224
// getting the evaluation result and validating it matches the results from SDK
225
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenCalledWith ( [ 'split1' ] , undefined ) ;
225
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenCalledWith ( [ 'split1' ] , undefined , undefined ) ;
226
226
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveReturnedWith ( actions [ 0 ] . payload . treatments ) ;
227
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenLastCalledWith ( [ 'split2' ] , undefined ) ;
227
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenLastCalledWith ( [ 'split2' ] , undefined , undefined ) ;
228
228
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( actions [ 1 ] . payload . treatments ) ;
229
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets ) . toHaveBeenLastCalledWith ( [ 'set1' ] , undefined ) ;
229
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets ) . toHaveBeenLastCalledWith ( [ 'set1' ] , undefined , undefined ) ;
230
230
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets ) . toHaveLastReturnedWith ( actions [ 2 ] . payload . treatments ) ;
231
231
232
232
expect ( getClient ( splitSdk ) . evalOnUpdate ) . toEqual ( { } ) ;
@@ -258,7 +258,7 @@ describe('getTreatments', () => {
258
258
treatments : expect . any ( Object )
259
259
}
260
260
} ) ;
261
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 1 , [ 'split1' ] , undefined ) ;
261
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 1 , [ 'split1' ] , undefined , undefined ) ;
262
262
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveNthReturnedWith ( 1 , action . payload . treatments ) ;
263
263
264
264
// getting the 2nd evaluation result and validating it matches the results from SDK
@@ -270,7 +270,7 @@ describe('getTreatments', () => {
270
270
treatments : expect . any ( Object )
271
271
}
272
272
} ) ;
273
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 2 , [ 'split2' , 'split3' ] , attributes ) ;
273
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 2 , [ 'split2' , 'split3' ] , attributes , undefined ) ;
274
274
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveNthReturnedWith ( 2 , action . payload . treatments ) ;
275
275
expect ( getClient ( splitSdk ) . evalOnUpdate ) . toEqual ( { } ) ; // control assertion - cbs scheduled for update
276
276
expect ( getClient ( splitSdk ) . evalOnReady . length ) . toEqual ( 2 ) ; // control assertion - cbs scheduled for ready
@@ -294,8 +294,8 @@ describe('getTreatments', () => {
294
294
expect ( store . getActions ( ) . length ) . toBe ( 4 ) ;
295
295
296
296
// getting the evaluation result and validating it matches the results from SDK calls
297
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 3 , [ 'split1' ] , undefined ) ;
298
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 4 , [ 'split2' , 'split3' ] , attributes ) ;
297
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 3 , [ 'split1' ] , undefined , undefined ) ;
298
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveBeenNthCalledWith ( 4 , [ 'split2' , 'split3' ] , attributes , undefined ) ;
299
299
const expectedTreatments = {
300
300
...( splitSdk . factory . client ( ) . getTreatmentsWithConfig as jest . Mock ) . mock . results [ 2 ] . value ,
301
301
...( splitSdk . factory . client ( ) . getTreatmentsWithConfig as jest . Mock ) . mock . results [ 3 ] . value ,
@@ -369,8 +369,8 @@ describe('getTreatments', () => {
369
369
370
370
// getting the evaluation result and validating it matches the results from SDK
371
371
const treatments = action . payload . treatments ;
372
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toBeCalledWith ( [ 'split2' ] , undefined ) ;
373
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets ) . toBeCalledWith ( [ 'set2' ] , undefined ) ;
372
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toBeCalledWith ( [ 'split2' ] , undefined , undefined ) ;
373
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets ) . toBeCalledWith ( [ 'set2' ] , undefined , undefined ) ;
374
374
expect ( treatments ) . toEqual ( {
375
375
...( splitSdk . factory . client ( ) . getTreatmentsWithConfig as jest . Mock ) . mock . results [ 0 ] . value ,
376
376
...( splitSdk . factory . client ( ) . getTreatmentsWithConfigByFlagSets as jest . Mock ) . mock . results [ 0 ] . value ,
@@ -395,7 +395,8 @@ describe('getTreatments', () => {
395
395
store . dispatch < any > ( initSplitSdk ( { config : sdkBrowserConfig , onTimedout : onTimedoutCb , onReadyFromCache : onReadyFromCacheCb , onReady : onReadyCb } ) ) ;
396
396
397
397
const attributes = { att1 : 'att1' } ;
398
- store . dispatch < any > ( getTreatments ( { splitNames : 'split3' , attributes, evalOnUpdate : true , evalOnReadyFromCache : true } ) ) ;
398
+ const properties = { prop1 : 'prop1' } ;
399
+ store . dispatch < any > ( getTreatments ( { splitNames : 'split3' , attributes, properties, evalOnUpdate : true , evalOnReadyFromCache : true } ) ) ;
399
400
400
401
// If SDK is not ready, an ADD_TREATMENTS action is dispatched with control treatments without calling SDK client
401
402
expect ( store . getActions ( ) . length ) . toBe ( 0 ) ;
@@ -436,7 +437,7 @@ describe('getTreatments', () => {
436
437
437
438
// getting the evaluation result and validating it matches the results from SDK
438
439
const treatments = action . payload . treatments ;
439
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes ) ;
440
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes , { properties } ) ;
440
441
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( treatments ) ;
441
442
}
442
443
@@ -458,7 +459,7 @@ describe('getTreatments', () => {
458
459
459
460
// getting the evaluation result and validating it matches the results from SDK
460
461
let treatments = action . payload . treatments ;
461
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes ) ;
462
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes , { properties } ) ;
462
463
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( treatments ) ;
463
464
464
465
expect ( Object . values ( getClient ( splitSdk ) . evalOnUpdate ) . length ) . toBe ( 1 ) ; // control assertion - We should have an item to evaluate on update
@@ -478,7 +479,7 @@ describe('getTreatments', () => {
478
479
479
480
// getting the evaluation result and validating it matches the results from SDK
480
481
treatments = action . payload . treatments ;
481
- expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes ) ;
482
+ expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split3' ] , attributes , { properties } ) ;
482
483
expect ( splitSdk . factory . client ( ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( treatments ) ;
483
484
484
485
expect ( Object . values ( getClient ( splitSdk ) . evalOnUpdate ) . length ) . toBe ( 1 ) ; // control assertion - still have one evalOnUpdate subscription
@@ -546,7 +547,7 @@ describe('getTreatments', () => {
546
547
}
547
548
} ) ;
548
549
549
- expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined ) ;
550
+ expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined , undefined ) ;
550
551
expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( action . payload . treatments ) ;
551
552
552
553
( splitSdk . factory as any ) . client ( 'other-user-key' ) . __emitter__ . emit ( Event . SDK_READY , 'other-user-key' ) ;
@@ -564,14 +565,15 @@ describe('getTreatments', () => {
564
565
} ) ;
565
566
566
567
// getting the evaluation result and validating it matches the results from SDK
567
- expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined ) ;
568
+ expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined , undefined ) ;
568
569
expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( action . payload . treatments ) ;
569
570
570
571
expect ( getClient ( splitSdk ) . evalOnUpdate ) . toEqual ( { } ) ; // control assertion
571
572
572
573
// The getTreatments is dispatched again, but this time is evaluated with attributes and registered for 'evalOnUpdate'
573
574
const attributes = { att1 : 'att1' } ;
574
- store . dispatch < any > ( getTreatments ( { splitNames : 'split2' , attributes, key : 'other-user-key' , evalOnUpdate : true } ) ) ;
575
+ const properties = { prop1 : 'prop1' } ;
576
+ store . dispatch < any > ( getTreatments ( { splitNames : 'split2' , attributes, properties, key : 'other-user-key' , evalOnUpdate : true } ) ) ;
575
577
action = store . getActions ( ) [ 4 ] ;
576
578
expect ( action ) . toEqual ( {
577
579
type : ADD_TREATMENTS ,
@@ -580,7 +582,7 @@ describe('getTreatments', () => {
580
582
treatments : expect . any ( Object )
581
583
}
582
584
} ) ;
583
- expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , attributes ) ;
585
+ expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , attributes , { properties } ) ;
584
586
expect ( Object . values ( getClient ( splitSdk , 'other-user-key' ) . evalOnUpdate ) . length ) . toBe ( 1 ) ; // control assertion - added evalOnUpdate subscription
585
587
586
588
// The SPLIT_UPDATE_WITH_EVALUATIONS action is dispatched when the SDK is updated for the new user key
@@ -595,7 +597,7 @@ describe('getTreatments', () => {
595
597
nonDefaultKey : true
596
598
}
597
599
} ) ;
598
- expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , attributes ) ;
600
+ expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , attributes , { properties } ) ;
599
601
expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( action . payload . treatments ) ;
600
602
expect ( Object . values ( getClient ( splitSdk , 'other-user-key' ) . evalOnUpdate ) . length ) . toBe ( 1 ) ; // control assertion - keeping evalOnUpdate subscription
601
603
@@ -609,7 +611,7 @@ describe('getTreatments', () => {
609
611
treatments : expect . any ( Object )
610
612
}
611
613
} ) ;
612
- expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined ) ;
614
+ expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . lastCalledWith ( [ 'split2' ] , undefined , undefined ) ;
613
615
expect ( splitSdk . factory . client ( 'other-user-key' ) . getTreatmentsWithConfig ) . toHaveLastReturnedWith ( action . payload . treatments ) ;
614
616
expect ( Object . values ( getClient ( splitSdk ) . evalOnUpdate ) . length ) . toBe ( 0 ) ; // control assertion - removed evalOnUpdate subscription
615
617
0 commit comments