11/****************************************************************************
2- * Copyright 2020, Optimizely, Inc. and contributors *
2+ * Copyright 2020-2021 , Optimizely, Inc. and contributors *
33 * *
44 * Licensed under the Apache License, Version 2.0 (the "License"); *
55 * you may not use this file except in compliance with the License. *
@@ -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 { CONTROL_ATTRIBUTES , DECISION_MESSAGES , LOG_LEVEL , LOG_MESSAGES } from '../utils/enums' ;
29+ import { CONTROL_ATTRIBUTES , LOG_LEVEL , LOG_MESSAGES } from '../utils/enums' ;
3030import testData from '../tests/test_data' ;
3131import { OptimizelyDecideOption } from '../shared_types' ;
3232
@@ -314,7 +314,7 @@ describe('lib/optimizely_user_context', function() {
314314 afterEach ( function ( ) {
315315 logging . resetLogger ( ) ;
316316 } ) ;
317- it ( 'should return false when client is not ready' , function ( ) {
317+ it ( 'should return true when client is not ready' , function ( ) {
318318 fakeOptimizely = {
319319 isValidInstance : sinon . stub ( ) . returns ( false )
320320 } ;
@@ -323,9 +323,8 @@ describe('lib/optimizely_user_context', function() {
323323 userId,
324324 } ) ;
325325 var result = user . setForcedDecision ( { flagKey : 'feature_1' } , '3324490562' ) ;
326- assert . strictEqual ( result , false ) ;
327- sinon . assert . calledOnce ( stubLogHandler . log ) ;
328- assert . strictEqual ( stubLogHandler . log . args [ 0 ] [ 1 ] , DECISION_MESSAGES . SDK_NOT_READY ) ;
326+ assert . strictEqual ( result , true ) ;
327+ sinon . assert . notCalled ( stubLogHandler . log ) ;
329328 } ) ;
330329
331330 it ( 'should return true when provided empty string flagKey' , function ( ) {
@@ -848,18 +847,17 @@ describe('lib/optimizely_user_context', function() {
848847 logging . resetLogger ( ) ;
849848 } ) ;
850849
851- it ( 'should return false when client is not ready' , function ( ) {
850+ it ( 'should return true when client is not ready and the forced decision has been removed successfully ' , function ( ) {
852851 fakeOptimizely = {
853852 isValidInstance : sinon . stub ( ) . returns ( false )
854853 } ;
855854 var user = new OptimizelyUserContext ( {
856855 optimizely : fakeOptimizely ,
857- userId,
856+ userId : 'user123' ,
858857 } ) ;
859- var result = user . removeForcedDecision ( 'feature_1' ) ;
860- assert . strictEqual ( result , false ) ;
861- sinon . assert . calledOnce ( stubLogHandler . log ) ;
862- assert . strictEqual ( stubLogHandler . log . args [ 0 ] [ 1 ] , DECISION_MESSAGES . SDK_NOT_READY ) ;
858+ user . setForcedDecision ( { flagKey : 'feature_1' } , '3324490562' ) ;
859+ var result = user . removeForcedDecision ( { flagKey : 'feature_1' } ) ;
860+ assert . strictEqual ( result , true ) ;
863861 } ) ;
864862
865863 it ( 'should return true when the forced decision has been removed successfully and false otherwise' , function ( ) {
@@ -923,7 +921,7 @@ describe('lib/optimizely_user_context', function() {
923921 logging . resetLogger ( ) ;
924922 } ) ;
925923
926- it ( 'should return false when client is not ready' , function ( ) {
924+ it ( 'should return true when client is not ready' , function ( ) {
927925 fakeOptimizely = {
928926 isValidInstance : sinon . stub ( ) . returns ( false )
929927 } ;
@@ -932,9 +930,8 @@ describe('lib/optimizely_user_context', function() {
932930 userId,
933931 } ) ;
934932 var result = user . removeAllForcedDecisions ( ) ;
935- assert . strictEqual ( result , false ) ;
936- sinon . assert . calledOnce ( stubLogHandler . log ) ;
937- assert . strictEqual ( stubLogHandler . log . args [ 0 ] [ 1 ] , DECISION_MESSAGES . SDK_NOT_READY ) ;
933+ assert . strictEqual ( result , true ) ;
934+ sinon . assert . notCalled ( stubLogHandler . log ) ;
938935 } ) ;
939936
940937 it ( 'should return true when all forced decisions have been removed successfully' , function ( ) {
0 commit comments