@@ -22,7 +22,6 @@ import Optimizely from './optimizely';
22
22
import testData from './tests/test_data' ;
23
23
import packageJSON from '../package.json' ;
24
24
import optimizelyFactory from './index.browser' ;
25
- import configValidator from './utils/config_validator' ;
26
25
import eventProcessorConfigValidator from './utils/event_processor_config_validator' ;
27
26
28
27
var LocalStoragePendingEventsDispatcher = eventProcessor . LocalStoragePendingEventsDispatcher ;
@@ -60,7 +59,6 @@ describe('javascript-sdk', function() {
60
59
logToConsole : false ,
61
60
} ) ;
62
61
sinon . spy ( console , 'error' ) ;
63
- sinon . stub ( configValidator , 'validate' ) ;
64
62
65
63
global . XMLHttpRequest = sinon . useFakeXMLHttpRequest ( ) ;
66
64
@@ -71,7 +69,6 @@ describe('javascript-sdk', function() {
71
69
LocalStoragePendingEventsDispatcher . prototype . sendPendingEvents . restore ( ) ;
72
70
optimizelyFactory . __internalResetRetryState ( ) ;
73
71
console . error . restore ( ) ;
74
- configValidator . validate . restore ( ) ;
75
72
delete global . XMLHttpRequest
76
73
} ) ;
77
74
@@ -125,12 +122,33 @@ describe('javascript-sdk', function() {
125
122
sinon . assert . calledOnce ( LocalStoragePendingEventsDispatcher . prototype . sendPendingEvents ) ;
126
123
} ) ;
127
124
128
- it ( 'should not throw if the provided config is not valid' , function ( ) {
129
- configValidator . validate . throws ( new Error ( 'Invalid config or something' ) ) ;
125
+ it ( 'should not throw an error if the provided config contains an invalid errorHandler' , function ( ) {
130
126
assert . doesNotThrow ( function ( ) {
131
127
var optlyInstance = optimizelyFactory . createInstance ( {
132
128
datafile : { } ,
133
- logger : silentLogger ,
129
+ errorHandler : 'invalid errorHandler' ,
130
+ } ) ;
131
+ // Invalid datafile causes onReady Promise rejection - catch this error
132
+ optlyInstance . onReady ( ) . catch ( function ( ) { } ) ;
133
+ } ) ;
134
+ } ) ;
135
+
136
+ it ( 'should not throw an error if the provided config contains an invalid logger' , function ( ) {
137
+ assert . doesNotThrow ( function ( ) {
138
+ var optlyInstance = optimizelyFactory . createInstance ( {
139
+ datafile : { } ,
140
+ logger : 'invalid logger' ,
141
+ } ) ;
142
+ // Invalid datafile causes onReady Promise rejection - catch this error
143
+ optlyInstance . onReady ( ) . catch ( function ( ) { } ) ;
144
+ } ) ;
<
628C
/code>
145
+ } ) ;
146
+
147
+ it ( 'should not throw an error if the provided config contains an invalid eventDispatcher' , function ( ) {
148
+ assert . doesNotThrow ( function ( ) {
149
+ var optlyInstance = optimizelyFactory . createInstance ( {
150
+ datafile : { } ,
151
+ eventDispatcher : 'invalid eventDispatcher' ,
134
152
} ) ;
135
153
// Invalid datafile causes onReady Promise rejection - catch this error
136
154
optlyInstance . onReady ( ) . catch ( function ( ) { } ) ;
0 commit comments