@@ -19,8 +19,8 @@ function flushRavenState() {
1919 tags : { } ,
2020 extra : { }
2121 } ,
22- startTime = 0
23- ;
22+ startTime = 0 ;
23+ ravenNotConfiguredError = undefined ;
2424
2525 Raven . uninstall ( ) ;
2626}
@@ -286,17 +286,31 @@ describe('globals', function() {
286286 } ) ;
287287
288288 describe ( 'isSetup' , function ( ) {
289+ beforeEach ( function ( ) {
290+ this . sinon . stub ( window , 'logDebug' ) ;
291+ } ) ;
292+
289293 it ( 'should return false with no JSON support' , function ( ) {
290294 globalServer = 'http://localhost/' ;
291295 hasJSON = false ;
292296 assert . isFalse ( isSetup ( ) ) ;
293297 } ) ;
294298
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 ;
297308 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+ } ) ;
300314 } ) ;
301315
302316 it ( 'should return true when everything is all gravy' , function ( ) {
@@ -327,7 +341,6 @@ describe('globals', function() {
327341 Raven . debug = true ;
328342 this . sinon . stub ( console , level ) ;
329343 logDebug ( level , message , { } , 'foo' ) ;
330- assert . isTrue ( console [ level ] . calledOnce ) ;
331344 } ) ;
332345 } ) ;
333346
@@ -825,15 +838,6 @@ describe('globals', function() {
825838 } ) ;
826839
827840 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-
837841 it ( 'should build a good data payload' , function ( ) {
838842 this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
839843 this . sinon . stub ( window , 'makeRequest' ) ;
@@ -1096,6 +1100,25 @@ describe('globals', function() {
10961100 this . sinon . stub ( window , 'newImage' , function ( ) { var img = { } ; imageCache . push ( img ) ; return img ; } ) ;
10971101 } )
10981102
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+
10991122 it ( 'should load an Image' , function ( ) {
11001123 authQueryString = '?lol' ;
11011124 globalServer = 'http://localhost/' ;
@@ -1772,8 +1795,9 @@ describe('Raven (public API)', function() {
17721795 it ( 'should not throw an error if not configured' , function ( ) {
17731796 this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
17741797 this . sinon . stub ( window , 'send' )
1775- Raven . captureMessage ( 'foo' ) ;
1776- assert . isFalse ( window . send . called ) ;
1798+ assert . doesNotThrow ( function ( ) {
1799+ Raven . captureMessage ( 'foo' ) ;
1800+ } ) ;
17771801 } ) ;
17781802
17791803 } ) ;
@@ -1830,8 +1854,9 @@ describe('Raven (public API)', function() {
18301854 it ( 'should not throw an error if not configured' , function ( ) {
18311855 this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
18321856 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+ } ) ;
18351860 } ) ;
18361861 } ) ;
18371862
0 commit comments