@@ -1355,5 +1355,47 @@ describe('lib/core/decision_service', function() {
1355
1355
} ) ;
1356
1356
} ) ;
1357
1357
} ) ;
1358
+
1359
+ describe ( '_getVariationForRollout' , function ( ) {
1360
+ var feature ;
1361
+ var configObj ;
1362
+ var decisionService ;
1363
+ var __buildBucketerParamsSpy ;
1364
+
1365
+ beforeEach ( function ( ) {
1366
+ configObj = projectConfig . createProjectConfig ( testDataWithFeatures ) ;
1367
+ feature = configObj . featureKeyMap . test_feature ;
1368
+ decisionService = DecisionService . createDecisionService ( {
1369
+ configObj : configObj ,
1370
+ logger : logger . createLogger ( { logLevel : LOG_LEVEL . INFO } ) ,
1371
+ } ) ;
1372
+ __buildBucketerParamsSpy = sinon . spy ( decisionService , '__buildBucketerParams' ) ;
1373
+ } ) ;
1374
+
1375
+ afterEach ( function ( ) {
1376
+ __buildBucketerParamsSpy . restore ( ) ;
1377
+ } ) ;
1378
+
1379
+ it ( 'should call __buildBucketerParams with user Id when bucketing Id is not provided in the attributes' , function ( ) {
1380
+ var attributes = { test_attribute : 'test_value' } ;
1381
+ decisionService . _getVariationForRollout ( feature , 'testUser' , attributes ) ;
1382
+
1383
+ sinon . assert . callCount ( __buildBucketerParamsSpy , 2 ) ;
1384
+ sinon . assert . calledWithExactly ( __buildBucketerParamsSpy , '594031' , 'testUser' , 'testUser' ) ;
1385
+ sinon . assert . calledWithExactly ( __buildBucketerParamsSpy , '594037' , 'testUser' , 'testUser' ) ;
1386
+ } ) ;
1387
+
1388
+ it ( 'should call __buildBucketerParams with bucketing Id when bucketing Id is provided in the attributes' , function ( ) {
1389
+ var attributes = {
1390
+ test_attribute : 'test_value' ,
1391
+ $opt_bucketing_id : 'abcdefg'
1392
+ } ;
1393
+ decisionService . _getVariationForRollout ( feature , 'testUser' , attributes ) ;
1394
+
1395
+ sinon . assert . callCount ( __buildBucketerParamsSpy , 2 ) ;
1396
+ sinon . assert . calledWithExactly ( __buildBucketerParamsSpy , '594031' , 'abcdefg' , 'testUser' ) ;
1397
+ sinon . assert . calledWithExactly ( __buildBucketerParamsSpy , '594037' , 'abcdefg' , 'testUser' ) ;
1398
+ } ) ;
1399
+ } ) ;
1358
1400
} ) ;
1359
1401
} ) ;
0 commit comments