@@ -1680,17 +1680,21 @@ describe('Raven (public API)', function() {
16801680
16811681 describe ( '.captureMessage' , function ( ) {
16821682 it ( 'should work as advertised' , function ( ) {
1683+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
16831684 this . sinon . stub ( window , 'send' ) ;
16841685 Raven . captureMessage ( 'lol' , { foo : 'bar' } ) ;
1686+ assert . isTrue ( window . send . called ) ;
16851687 assert . deepEqual ( window . send . lastCall . args , [ {
16861688 message : 'lol' ,
16871689 foo : 'bar'
16881690 } ] ) ;
16891691 } ) ;
16901692
16911693 it ( 'should coerce message to a string' , function ( ) {
1694+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
16921695 this . sinon . stub ( window , 'send' ) ;
16931696 Raven . captureMessage ( { } ) ;
1697+ assert . isTrue ( window . send . called ) ;
16941698 assert . deepEqual ( window . send . lastCall . args , [ {
16951699 message : '[object Object]'
16961700 } ] ) ;
@@ -1716,6 +1720,7 @@ describe('Raven (public API)', function() {
17161720 } ) ;
17171721
17181722 it ( 'should respect `ignoreErrors`' , function ( ) {
1723+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17191724 this . sinon . stub ( window , 'send' ) ;
17201725
17211726 globalOptions . ignoreErrors = joinRegExp ( [ 'e1' , 'e2' ] ) ;
@@ -1726,25 +1731,36 @@ describe('Raven (public API)', function() {
17261731 Raven . captureMessage ( 'Non-ignored error' ) ;
17271732 assert . isTrue ( window . send . calledOnce ) ;
17281733 } ) ;
1734+
1735+ it ( 'should not throw an error if not configured' , function ( ) {
1736+ this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
1737+ this . sinon . stub ( window , 'send' )
1738+ Raven . captureMessage ( 'foo' ) ;
1739+ assert . isFalse ( window . send . called ) ;
1740+ } ) ;
1741+
17291742 } ) ;
17301743
17311744 describe ( '.captureException' , function ( ) {
17321745 it ( 'should call handleStackInfo' , function ( ) {
17331746 var error = new Error ( 'crap' ) ;
1747+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17341748 this . sinon . stub ( window , 'handleStackInfo' ) ;
17351749 Raven . captureException ( error , { foo : 'bar' } ) ;
17361750 assert . isTrue ( window . handleStackInfo . calledOnce ) ;
17371751 } ) ;
17381752
17391753 it ( 'should store the last exception' , function ( ) {
17401754 var error = new Error ( 'crap' ) ;
1755+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17411756 this . sinon . stub ( window , 'handleStackInfo' ) ;
17421757 Raven . captureException ( error ) ;
17431758 assert . equal ( Raven . lastException ( ) , error ) ;
17441759 } ) ;
17451760
1746- it ( 'shouldn\'t reraise the if the error is the same error' , function ( ) {
1761+ it ( 'shouldn\'t reraise the if error is the same error' , function ( ) {
17471762 var error = new Error ( 'crap' ) ;
1763+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17481764 this . sinon . stub ( window , 'handleStackInfo' ) . throws ( error ) ;
17491765 // this would raise if the errors didn't match
17501766 Raven . captureException ( error , { foo : 'bar' } ) ;
@@ -1753,22 +1769,33 @@ describe('Raven (public API)', function() {
17531769
17541770 it ( 'should reraise a different error' , function ( ) {
17551771 var error = new Error ( 'crap1' ) ;
1772+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17561773 this . sinon . stub ( window , 'handleStackInfo' ) . throws ( error ) ;
17571774 assert . throws ( function ( ) {
17581775 Raven . captureException ( new Error ( 'crap2' ) ) ;
17591776 } , error ) ;
17601777 } ) ;
17611778
17621779 it ( 'should capture as a normal message if a non-Error is passed' , function ( ) {
1780+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
17631781 this . sinon . stub ( Raven , 'captureMessage' ) ;
17641782 this . sinon . stub ( window , 'handleStackInfo' )
17651783 Raven . captureException ( 'derp' ) ;
1784+ assert . isTrue ( Raven . captureMessage . called ) ;
17661785 assert . equal ( Raven . captureMessage . lastCall . args [ 0 ] , 'derp' ) ;
17671786 assert . isFalse ( window . handleStackInfo . called ) ;
17681787 Raven . captureException ( true ) ;
1788+ assert . isTrue ( Raven . captureMessage . called ) ;
17691789 assert . equal ( Raven . captureMessage . lastCall . args [ 0 ] , true ) ;
17701790 assert . isFalse ( window . handleStackInfo . called ) ;
17711791 } ) ;
1792+
1793+ it ( 'should not throw an error if not configured' , function ( ) {
1794+ this . sinon . stub ( Raven , 'isSetup' ) . returns ( false ) ;
1795+ this . sinon . stub ( window , 'handleStackInfo' )
1796+ Raven . captureException ( new Error ( 'err' ) ) ;
1797+ assert . isFalse ( window . handleStackInfo . called ) ;
1798+ } ) ;
17721799 } ) ;
17731800
17741801 describe ( '.isSetup' , function ( ) {
0 commit comments