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