@@ -51,15 +51,13 @@ var createLogger = () => ({
51
51
} ) ;
52
52
53
53
const getOptlyInstance = ( { datafileObj, defaultDecideOptions } ) => {
54
- const createdLogger = logger . createLogger ( { logLevel : LOG_LEVEL . INFO } ) ;
54
+ const createdLogger = createLogger ( { logLevel : LOG_LEVEL . INFO } ) ;
55
55
const mockConfigManager = getMockProjectConfigManager ( {
56
56
initConfig : createProjectConfig ( datafileObj ) ,
57
57
} ) ;
58
58
const eventDispatcher = getMockEventDispatcher ( ) ;
59
59
const eventProcessor = getForwardingEventProcessor ( eventDispatcher ) ;
60
60
61
- const notificationCenter = createNotificationCenter ( { logger : createdLogger , errorHandler : errorHandler } ) ;
62
-
63
61
const optlyInstance = new Optimizely ( {
64
62
clientEngine : 'node-sdk' ,
65
63
projectConfigManager : mockConfigManager ,
@@ -69,12 +67,10 @@ const getOptlyInstance = ({ datafileObj, defaultDecideOptions }) => {
69
67
isValidInstance : true ,
70
68
eventBatchSize : 1 ,
71
69
defaultDecideOptions : defaultDecideOptions || [ ] ,
72
- notificationCenter,
73
70
} ) ;
74
71
75
- sinon . stub ( notificationCenter , 'sendNotifications' ) ;
76
72
77
- return { optlyInstance, eventProcessor, eventDispatcher, notificationCenter , createdLogger }
73
+ return { optlyInstance, eventProcessor, eventDispatcher, createdLogger }
78
74
}
79
75
80
76
describe ( 'lib/optimizely_user_context' , function ( ) {
@@ -341,25 +337,17 @@ describe('lib/optimizely_user_context', function() {
341
337
logLevel : LOG_LEVEL . DEBUG ,
342
338
logToConsole : false ,
343
339
} ) ;
344
- var stubLogHandler ;
345
- let optlyInstance , notificationCenter , eventDispatcher ;
346
340
347
- beforeEach ( function ( ) {
348
- stubLogHandler = {
349
- log : sinon . stub ( ) ,
350
- } ;
351
- logging . setLogLevel ( 'notset' ) ;
352
- logging . setLogHandler ( stubLogHandler ) ;
341
+ let optlyInstance , eventDispatcher ;
353
342
354
- ( { optlyInstance, notificationCenter, createdLogger, eventDispatcher} = getOptlyInstance ( {
343
+ beforeEach ( function ( ) {
344
+ ( { optlyInstance, createdLogger, eventDispatcher} = getOptlyInstance ( {
355
345
datafileObj : testData . getTestDecideProjectConfig ( ) ,
356
346
} ) ) ;
357
347
} ) ;
358
348
359
349
afterEach ( function ( ) {
360
- logging . resetLogger ( ) ;
361
350
eventDispatcher . dispatchEvent . reset ( ) ;
362
- notificationCenter . sendNotifications . restore ( ) ;
363
351
} ) ;
364
352
365
353
it ( 'should return true when client is not ready' , function ( ) {
@@ -426,7 +414,7 @@ describe('lib/optimizely_user_context', function() {
426
414
} ) ;
427
415
428
416
afterEach ( function ( ) {
429
- optlyInstance . decisionService . logger . log . restore ( ) ;
417
+ // optlyInstance.decisionService.logger.log.restore();
430
418
eventDispatcher . dispatchEvent . reset ( ) ;
431
419
optlyInstance . notificationCenter . sendNotifications . restore ( ) ;
432
420
} ) ;
@@ -504,10 +492,13 @@ describe('lib/optimizely_user_context', function() {
504
492
} ) ;
505
493
506
494
it ( 'should return forced decision object when forced decision is set for a flag and dispatch an event' , function ( ) {
507
- const { optlyInstance, notificationCenter , eventDispatcher } = getOptlyInstance ( {
495
+ const { optlyInstance, eventDispatcher } = getOptlyInstance ( {
508
496
datafileObj : testData . getTestDecideProjectConfig ( ) ,
509
497
} ) ;
510
498
499
+ const notificationCenter = optlyInstance . notificationCenter ;
500
+ sinon . stub ( notificationCenter , 'sendNotifications' ) ;
501
+
511
502
var user = optlyInstance . createUserContext ( userId ) ;
512
503
var featureKey = 'feature_1' ;
513
504
var variationKey = '3324490562' ;
@@ -583,9 +574,13 @@ describe('lib/optimizely_user_context', function() {
583
574
} ) ;
584
575
585
576
it ( 'should return forced decision object when forced decision is set for an experiment rule and dispatch an event' , function ( ) {
586
- const { optlyInstance, notificationCenter , eventDispatcher } = getOptlyInstance ( {
577
+ const { optlyInstance, eventDispatcher } = getOptlyInstance ( {
587
578
datafileObj : testData . getTestDecideProjectConfig ( ) ,
588
579
} ) ;
580
+
581
+ const notificationCenter = optlyInstance . notificationCenter ;
582
+ sinon . stub ( notificationCenter , 'sendNotifications' ) ;
583
+
589
584
var attributes = { country : 'US' } ;
590
585
var user = optlyInstance . createUserContext ( userId , attributes ) ;
591
586
var featureKey = 'feature_1' ;
@@ -668,9 +663,13 @@ describe('lib/optimizely_user_context', function() {
668
663
} ) ;
669
664
670
665
it ( 'should return forced decision object when forced decision is set for a delivery rule and dispatch an event' , function ( ) {
671
- const { optlyInstance, notificationCenter , eventDispatcher } = getOptlyInstance ( {
666
+ const { optlyInstance, eventDispatcher } = getOptlyInstance ( {
672
667
datafileObj : testData . getTestDecideProjectConfig ( ) ,
673
668
} ) ;
669
+
670
+ const notificationCenter = optlyInstance . notificationCenter ;
671
+ sinon . stub ( notificationCenter , 'sendNotifications' ) ;
672
+
674
673
var user = optlyInstance . createUserContext ( userId ) ;
675
674
var featureKey = 'feature_1' ;
676
675
var variationKey = '3324490633' ;
@@ -939,18 +938,6 @@ describe('lib/optimizely_user_context', function() {
939
938
} ) ;
940
939
941
940
describe ( '#removeForcedDecision' , function ( ) {
942
- var stubLogHandler ;
943
- beforeEach ( function ( ) {
944
- stubLogHandler = {
945
- log : sinon . stub ( ) ,
946
- } ;
947
- logging . setLogLevel ( 'notset' ) ;
948
- logging . setLogHandler ( stubLogHandler ) ;
949
- } ) ;
950
- afterEach ( function ( ) {
951
- logging . resetLogger ( ) ;
952
- } ) ;
953
-
954
941
it ( 'should return true when client is not ready and the forced decision has been removed successfully' , function ( ) {
955
942
fakeOptimizely = {
956
943
isValidInstance : sinon . stub ( ) . returns ( false ) ,
@@ -1014,18 +1001,6 @@ describe('lib/optimizely_user_context', function() {
1014
1001
} ) ;
1015
1002
1016
1003
describe ( '#removeAllForcedDecisions' , function ( ) {
1017
- var stubLogHandler ;
1018
- beforeEach ( function ( ) {
1019
- stubLogHandler = {
1020
- log : sinon . stub ( ) ,
1021
- } ;
1022
- logging . setLogLevel ( 'notset' ) ;
1023
- logging . setLogHandler ( stubLogHandler ) ;
1024
- } ) ;
1025
- afterEach ( function ( ) {
1026
- logging . resetLogger ( ) ;
1027
- } ) ;
1028
-
1029
1004
it ( 'should return true when client is not ready' , function ( ) {
1030
1005
fakeOptimizely = {
1031
1006
isValidInstance : sinon . stub ( ) . returns ( false ) ,
0 commit comments