1
1
/****************************************************************************
2
- * Copyright 2020, Optimizely, Inc. and contributors *
2
+ * Copyright 2020-2021 , Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
@@ -26,7 +26,7 @@ import { createNotificationCenter } from '../core/notification_center';
26
26
import Optimizely from '../optimizely' ;
27
27
import errorHandler from '../plugins/error_handler' ;
28
28
import 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' ;
30
30
import testData from '../tests/test_data' ;
31
31
import { OptimizelyDecideOption } from '../shared_types' ;
32
32
@@ -314,7 +314,7 @@ describe('lib/optimizely_user_context', function() {
314
314
afterEach ( function ( ) {
315
315
logging . resetLogger ( ) ;
316
316
} ) ;
317
- it ( 'should return false when client is not ready' , function ( ) {
317
+ it ( 'should return true when client is not ready' , function ( ) {
318
318
fakeOptimizely = {
319
319
isValidInstance : sinon . stub ( ) . returns ( false )
320
320
} ;
@@ -323,9 +323,8 @@ describe('lib/optimizely_user_context', function() {
323
323
userId,
324
324
} ) ;
325
325
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 ) ;
329
328
} ) ;
330
329
331
330
it ( 'should return true when provided empty string flagKey' , function ( ) {
@@ -848,18 +847,17 @@ describe('lib/optimizely_user_context', function() {
848
847
logging . resetLogger ( ) ;
849
848
} ) ;
850
849
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 ( ) {
852
851
fakeOptimizely = {
853
852
isValidInstance : sinon . stub ( ) . returns ( false )
854
853
} ;
855
854
var user = new OptimizelyUserContext ( {
856
855
optimizely : fakeOptimizely ,
857
- userId,
856
+ userId : 'user123' ,
858
857
} ) ;
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 ) ;
863
861
} ) ;
864
862
865
863
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() {
923
921
logging . resetLogger ( ) ;
924
922
} ) ;
925
923
926
- it ( 'should return false when client is not ready' , function ( ) {
924
+ it ( 'should return true when client is not ready' , function ( ) {
927
925
fakeOptimizely = {
928
926
isValidInstance : sinon . stub ( ) . returns ( false )
929
927
} ;
@@ -932,9 +930,8 @@ describe('lib/optimizely_user_context', function() {
932
930
userId,
933
931
} ) ;
934
932
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 ) ;
938
935
} ) ;
939
936
940
937
it ( 'should return true when all forced decisions have been removed successfully' , function ( ) {
0 commit comments