@@ -218,31 +218,32 @@ describe('globals', function() {
218
218
it ( 'should return false when Raven is not configured' , function ( ) {
219
219
hasJSON = true ; // be explicit
220
220
globalServer = undefined ;
221
- this . sinon . stub ( console , 'error ' ) ;
221
+ this . sinon . stub ( window , 'logDebug ' ) ;
222
222
assert . isFalse ( isSetup ( ) ) ;
223
223
} ) ;
224
224
225
- it ( 'should not write to console.error when Raven is not configured and Raven.debug is false' , function ( ) {
226
- hasJSON = true ; // be explicit
227
- globalServer = undefined ;
228
- Raven . debug = false ;
229
- this . sinon . stub ( console , 'error' ) ;
230
- isSetup ( ) ;
231
- assert . isFalse ( console . error . calledOnce ) ;
225
+ it ( 'should return true when everything is all gravy' , function ( ) {
226
+ hasJSON = true ;
227
+ assert . isTrue ( isSetup ( ) ) ;
232
228
} ) ;
229
+ } ) ;
233
230
234
- it ( 'should write to console.error when Raven is not configured and Raven.debug is true' , function ( ) {
235
- hasJSON = true ; // be explicit
236
- globalServer = undefined ;
237
- Raven . debug = true ;
238
- this . sinon . stub ( console , 'error' ) ;
239
- isSetup ( ) ;
240
- assert . isTrue ( console . error . calledOnce ) ;
231
+ describe ( 'logDebug' , function ( ) {
232
+ var level = 'error' ,
233
+ message = 'foobar' ;
234
+
235
+ it ( 'should not write to console when Raven.debug is false' , function ( ) {
236
+ Raven . debug = false ;
237
+ this . sinon . stub ( console , level ) ;
238
+ logDebug ( level , message ) ;
239
+ assert . isFalse ( console [ level ] . called ) ;
241
240
} ) ;
242
241
243
- it ( 'should return true when everything is all gravy' , function ( ) {
244
- hasJSON = true ;
245
- assert . isTrue ( isSetup ( ) ) ;
242
+ it ( 'should write to console when Raven.debug is true' , function ( ) {
243
+ Raven . debug = true ;
244
+ this . sinon . stub ( console , level ) ;
245
+ logDebug ( level , message ) ;
246
+ assert . isTrue ( console [ level ] . calledOnce ) ;
246
247
} ) ;
247
248
} ) ;
248
249
@@ -1168,6 +1169,15 @@ describe('Raven (public API)', function() {
1168
1169
assert . equal ( Raven . config ( '' ) , Raven ) ;
1169
1170
} ) ;
1170
1171
1172
+ it ( 'should not set global options more than once' , function ( ) {
1173
+ this . sinon . spy ( window , 'parseDSN' ) ;
1174
+ this . sinon . stub ( window , 'logDebug' ) ;
1175
+ setupRaven ( ) ;
1176
+ setupRaven ( ) ;
1177
+ assert . isTrue ( parseDSN . calledOnce ) ;
1178
+ assert . isTrue ( logDebug . called ) ;
1179
+ } ) ;
1180
+
1171
1181
describe ( 'whitelistUrls' , function ( ) {
1172
1182
it ( 'should be false if none are passed' , function ( ) {
1173
1183
Raven . config ( '//[email protected] /2' ) ;
@@ -1237,6 +1247,14 @@ describe('Raven (public API)', function() {
1237
1247
assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
1238
1248
assert . equal ( TraceKit . report . subscribe . lastCall . args [ 0 ] , handleStackInfo ) ;
1239
1249
} ) ;
1250
+
1251
+ it ( 'should not register itself more than once' , function ( ) {
1252
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1253
+ this . sinon . stub ( TraceKit . report , 'subscribe' ) ;
1254
+ Raven . install ( ) ;
1255
+ Raven . install ( ) ;
1256
+ assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
1257
+ } ) ;
1240
1258
} ) ;
1241
1259
1242
1260
describe ( '.wrap' , function ( ) {
@@ -1382,6 +1400,13 @@ describe('Raven (public API)', function() {
1382
1400
Raven . uninstall ( ) ;
1383
1401
assert . isTrue ( TraceKit . report . uninstall . calledOnce ) ;
1384
1402
} ) ;
1403
+
1404
+ it ( 'should set isRavenInstalled flag to false' , function ( ) {
1405
+ isRavenInstalled = true ;
1406
+ this . sinon . stub ( TraceKit . report , 'uninstall' ) ;
1407
+ Raven . uninstall ( ) ;
1408
+ assert . isFalse ( isRavenInstalled ) ;
1409
+ } ) ;
1385
1410
} ) ;
1386
1411
1387
1412
describe ( '.setUserContext' , function ( ) {
0 commit comments