@@ -19,8 +19,8 @@ function flushRavenState() {
19
19
tags : { } ,
20
20
extra : { }
21
21
} ,
22
- startTime = 0
23
- ;
22
+ startTime = 0 ;
23
+ ravenNotConfiguredError = undefined ;
24
24
25
25
Raven . uninstall ( ) ;
26
26
}
@@ -286,17 +286,31 @@ describe('globals', function() {
286
286
} ) ;
287
287
288
288
describe ( 'isSetup' , function ( ) {
289
+ beforeEach ( function ( ) {
290
+ this . sinon . stub ( window , 'logDebug' ) ;
291
+ } ) ;
292
+
289
293
it ( 'should return false with no JSON support' , function ( ) {
290
294
globalServer = 'http://localhost/' ;
291
295
hasJSON = false ;
292
296
assert . isFalse ( isSetup ( ) ) ;
293
297
} ) ;
294
298
295
- it ( 'should return false when Raven is not configured' , function ( ) {
296
- hasJSON = true ; // be explicit
299
+ describe ( 'when Raven is not configured' , function ( ) {
300
+ it ( 'should return false when Raven is not configured' , function ( ) {
301
+ hasJSON = true ; // be explicit
302
+ globalServer = undefined ;
303
+ assert . isFalse ( isSetup ( ) ) ;
304
+ } ) ;
305
+
306
+ it ( 'should log an error message, the first time it is called' , function ( ) {
307
+ hasJSON = true ;
297
308
globalServer = undefined ;
298
- this . sinon . stub ( window , 'logDebug' ) ;
299
- assert . isFalse ( isSetup ( ) ) ;
309
+ isSetup ( ) ;
310
+ isSetup ( ) ;
311
+ assert . isTrue ( window . logDebug . calledWith ( 'error' , 'Error: Raven has not been configured.' ) )
312
+ assert . isTrue ( window . logDebug . calledOnce ) ;
313
+ } ) ;
300
314
} ) ;
301
315
302
316
it ( 'should return true when everything is all gravy' , function ( ) {
@@ -327,7 +341,6 @@ describe('globals', function() {
327
341
Raven . debug = true ;
328
342
this . sinon . stub ( console , level ) ;
329
343
logDebug ( level , message , { } , 'foo' ) ;
330
- assert . isTrue ( console [ level ] . calledOnce ) ;
331
344
} ) ;
332
345
} ) ;
333
346
@@ -825,15 +838,6 @@ describe('globals', function() {
825
838
} ) ;
826
839
827
840
describe ( 'send' , function ( ) {
828
- it ( 'should check `isSetup`' , function ( ) {
829
- this . sinon . stub ( window , 'isSetup' ) . returns ( false ) ;
830
- this . sinon . stub ( window , 'makeRequest' ) ;
831
-
832
- send ( ) ;
833
- assert . isTrue ( window . isSetup . calledOnce ) ;
834
- assert . isFalse ( window . makeRequest . calledOnce ) ;
835
- } ) ;
836
-
837
841
it ( 'should build a good data payload' , function ( ) {
838
842
this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
839
843
this . sinon . stub ( window , 'makeRequest' ) ;
@@ -1096,6 +1100,25 @@ describe('globals', function() {
1096
1100
this . sinon . stub ( window , 'newImage' , function ( ) { var img = { } ; imageCache . push ( img ) ; return img ; } ) ;
1097
1101
} )
1098
1102
1103
+ it ( 'should check `isSetup`' , function ( ) {
1104
+ this . sinon . stub ( window , 'isSetup' ) . returns ( false ) ;
1105
+ makeRequest ( { foo : 'bar' } ) ;
1106
+ assert . isTrue ( window . isSetup . called ) ;
1107
+ } ) ;
1108
+
1109
+ it ( 'should not create the image if `isSetup` is false' , function ( ) {
1110
+ this . sinon . stub ( window , 'isSetup' ) . returns ( false ) ;
1111
+ makeRequest ( { foo : 'bar' } ) ;
1112
+ assert . isFalse ( window . newImage . called ) ;
1113
+ } ) ;
1114
+
1115
+ it ( 'should log to console' , function ( ) {
1116
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1117
+ this . sinon . stub ( window , 'logDebug' ) ;
1118
+ makeRequest ( { foo : 'bar' } ) ;
1119
+ assert . isTrue ( window . logDebug . called ) ;
1120
+ } ) ;
1121
+
1099
1122
it ( 'should load an Image' , function ( ) {
1100
1123
authQueryString = '?lol' ;
1101
1124
globalServer = 'http://localhost/' ;
@@ -1772,8 +1795,9 @@ describe('Raven (public API)', function() {
1772
1795
it ( 'should not throw an error if not configured' , function ( ) {
1773
1796
this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
1774
1797
this . sinon . stub ( window , 'send' )
1775
- Raven . captureMessage ( 'foo' ) ;
1776
- assert . isFalse ( window . send . called ) ;
1798
+ assert . doesNotThrow ( function ( ) {
1799
+ Raven . captureMessage ( 'foo' ) ;
1800
+ } ) ;
1777
1801
} ) ;
1778
1802
1779
1803
} ) ;
@@ -1830,8 +1854,9 @@ describe('Raven (public API)', function() {
1830
1854
it ( 'should not throw an error if not configured' , function ( ) {
1831
1855
this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
1832
1856
this . sinon . stub ( window , 'handleStackInfo' )
1833
- Raven . captureException ( new Error ( 'err' ) ) ;
1834
- assert . isFalse ( window . handleStackInfo . called ) ;
1857
+ assert . doesNotThrow ( function ( ) {
1858
+ Raven . captureException ( new Error ( 'err' ) ) ;
1859
+ } ) ;
1835
1860
} ) ;
1836
1861
} ) ;
1837
1862
0 commit comments