@@ -230,6 +230,46 @@ describe('javascript-sdk', function() {
230
230
var variation = optlyInstance . getVariation ( 'testExperimentNotRunning' , 'testUser' ) ;
231
231
assert . strictEqual ( variation , null ) ;
232
232
} ) ;
233
+
234
+ describe ( 'automatically created logger instances' , function ( ) {
235
+ beforeEach ( function ( ) {
236
+ sinon . spy ( console , 'log' )
237
+ } ) ;
238
+
239
+ afterEach ( function ( ) {
240
+ console . log . restore ( ) ;
241
+ } ) ;
242
+
243
+ it ( 'should instantiate the logger with a custom logLevel when provided' , function ( ) {
244
+ // checking that INFO logs do not log for a logLevel of ERROR
245
+ var optlyInstance = window . optimizelySdk . createInstance ( {
246
+ datafile : testData . getTestProjectConfig ( ) ,
247
+ logLevel : enums . LOG_LEVEL . ERROR ,
248
+ skipJSONValidation : true
249
+ } ) ;
250
+ assert . strictEqual ( console . log . getCalls ( ) . length , 0 )
251
+
252
+ // checking that ERROR logs do log for a logLevel of ERROR
253
+ var optlyInstanceInvalid = window . optimizelySdk . createInstance ( {
254
+ datafile : { } ,
255
+ logLevel : enums . LOG_LEVEL . ERROR
256
+ } ) ;
257
+ optlyInstance . activate ( 'testExperiment' , 'testUser' )
258
+ assert . strictEqual ( console . error . getCalls ( ) . length , 1 )
259
+ } ) ;
260
+
261
+ it ( 'should default to INFO when no logLevel is provided' , function ( ) {
262
+ // checking that INFO logs log for an unspecified logLevel
263
+ var optlyInstance = window . optimizelySdk . createInstance ( {
264
+ datafile : testData . getTestProjectConfig ( ) ,
265
+ skipJSONValidation : true
266
+ } ) ;
267
+ assert . strictEqual ( console . log . getCalls ( ) . length , 1 )
268
+ call = console . log . getCalls ( ) [ 0 ]
269
+ assert . strictEqual ( call . args . length , 1 )
270
+ assert ( call . args [ 0 ] . indexOf ( 'OPTIMIZELY: Skipping JSON schema validation.' ) > - 1 )
271
+ } ) ;
272
+ } ) ;
233
273
} ) ;
234
274
} ) ;
235
275
} ) ;
0 commit comments