@@ -26,7 +26,7 @@ import { createNotificationCenter } from '../core/notification_center';
2626import Optimizely from '../optimizely' ;
2727import errorHandler from '../plugins/error_handler' ;
2828import eventDispatcher from '../plugins/event_dispatcher/index.node' ;
29- import { DECISION_MESSAGES , LOG_LEVEL , LOG_MESSAGES } from '../utils/enums' ;
29+ import { CONTROL_ATTRIBUTES , DECISION_MESSAGES , LOG_LEVEL , LOG_MESSAGES } from '../utils/enums' ;
3030import testData from '../tests/test_data' ;
3131import { OptimizelyDecideOption } from '../shared_types' ;
3232
@@ -328,7 +328,7 @@ describe('lib/optimizely_user_context', function() {
328328 assert . strictEqual ( stubLogHandler . log . args [ 0 ] [ 1 ] , DECISION_MESSAGES . SDK_NOT_READY ) ;
329329 } ) ;
330330
331- it ( 'should return false when provided empty string flagKey' , function ( ) {
331+ it ( 'should return true when provided empty string flagKey' , function ( ) {
332332 fakeOptimizely = {
333333 isValidInstance : sinon . stub ( ) . returns ( true )
334334 } ;
@@ -337,7 +337,7 @@ describe('lib/optimizely_user_context', function() {
337337 userId : 'user123' ,
338338 } ) ;
339339 var result = user . setForcedDecision ( { flagKey : '' } , '3324490562' ) ;
340- assert . strictEqual ( result , false ) ;
340+ assert . strictEqual ( result , true ) ;
341341 sinon . assert . notCalled ( stubLogHandler . log ) ;
342342 } ) ;
343343
@@ -400,7 +400,7 @@ describe('lib/optimizely_user_context', function() {
400400 assert . equal ( decision . userContext . getUserId ( ) , userId ) ;
401401 assert . deepEqual ( decision . userContext . getAttributes ( ) , { } ) ;
402402 assert . deepEqual ( Object . keys ( decision . userContext . forcedDecisionsMap ) . length , 1 ) ;
403- assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ '$null-rule-key' ] , { variationKey } ) ;
403+ assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ CONTROL_ATTRIBUTES . FORCED_DECISION_NULL_RULE_KEY ] , { variationKey } ) ;
404404 assert . equal (
405405 true ,
406406 decision . reasons . includes (
@@ -429,7 +429,7 @@ describe('lib/optimizely_user_context', function() {
429429 assert . equal ( decision . userContext . getUserId ( ) , userId ) ;
430430 assert . deepEqual ( decision . userContext . getAttributes ( ) , { } ) ;
431431 assert . deepEqual ( Object . values ( decision . userContext . forcedDecisionsMap ) . length , 1 ) ;
432- assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ '$null-rule-key' ] , { variationKey } ) ;
432+ assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ CONTROL_ATTRIBUTES . FORCED_DECISION_NULL_RULE_KEY ] , { variationKey } ) ;
433433 assert . equal (
434434 true ,
435435 decision . reasons . includes (
@@ -448,7 +448,7 @@ describe('lib/optimizely_user_context', function() {
448448 var eventDecision = impressionEvent . params . visitors [ 0 ] . snapshots [ 0 ] . decisions [ 0 ] ;
449449 var metadata = eventDecision . metadata ;
450450
451- assert . equal ( eventDecision . experiment_id , null ) ;
451+ assert . equal ( eventDecision . experiment_id , '' ) ;
452452 assert . equal ( eventDecision . variation_id , '3324490562' ) ;
453453
454454 assert . equal ( metadata . flag_key , featureKey ) ;
@@ -561,6 +561,7 @@ describe('lib/optimizely_user_context', function() {
561561 } ,
562562 decisionEventDispatched : true ,
563563 reasons : [
564+
564565 sprintf (
565566 LOG_MESSAGES . USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED ,
566567 variationKey ,
@@ -681,7 +682,7 @@ describe('lib/optimizely_user_context', function() {
681682 assert . equal ( decision . variationKey , '18257766532' ) ;
682683 assert . equal ( decision . ruleKey , '18322080788' ) ;
683684 assert . deepEqual ( Object . keys ( decision . userContext . forcedDecisionsMap ) . length , 1 ) ;
684- assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ '$null-rule-key' ] , { variationKey } ) ;
685+ assert . deepEqual ( decision . userContext . forcedDecisionsMap [ featureKey ] [ CONTROL_ATTRIBUTES . FORCED_DECISION_NULL_RULE_KEY ] , { variationKey } ) ;
685686 assert . equal (
686687 true ,
687688 decision . reasons . includes (
0 commit comments