@@ -1680,17 +1680,21 @@ describe('Raven (public API)', function() {
1680
1680
1681
1681
describe ( '.captureMessage' , function ( ) {
1682
1682
it ( 'should work as advertised' , function ( ) {
1683
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1683
1684
this . sinon . stub ( window , 'send' ) ;
1684
1685
Raven . captureMessage ( 'lol' , { foo : 'bar' } ) ;
1686
+ assert . isTrue ( window . send . called ) ;
1685
1687
assert . deepEqual ( window . send . lastCall . args , [ {
1686
1688
message : 'lol' ,
1687
1689
foo : 'bar'
1688
1690
} ] ) ;
1689
1691
} ) ;
1690
1692
1691
1693
it ( 'should coerce message to a string' , function ( ) {
1694
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1692
1695
this . sinon . stub ( window , 'send' ) ;
1693
1696
Raven . captureMessage ( { } ) ;
1697
+ assert . isTrue ( window . send . called ) ;
1694
1698
assert . deepEqual ( window . send . lastCall . args , [ {
1695
1699
message : '[object Object]'
1696
1700
} ] ) ;
@@ -1716,6 +1720,7 @@ describe('Raven (public API)', function() {
1716
1720
} ) ;
1717
1721
1718
1722
it ( 'should respect `ignoreErrors`' , function ( ) {
1723
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1719
1724
this . sinon . stub ( window , 'send' ) ;
1720
1725
1721
1726
globalOptions . ignoreErrors = joinRegExp ( [ 'e1' , 'e2' ] ) ;
@@ -1726,25 +1731,36 @@ describe('Raven (public API)', function() {
1726
1731
Raven . captureMessage ( 'Non-ignored error' ) ;
1727
1732
assert . isTrue ( window . send . calledOnce ) ;
1728
1733
} ) ;
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
+
1729
1742
} ) ;
1730
1743
1731
1744
describe ( '.captureException' , function ( ) {
1732
1745
it ( 'should call handleStackInfo' , function ( ) {
1733
1746
var error = new Error ( 'crap' ) ;
1747
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1734
1748
this . sinon . stub ( window , 'handleStackInfo' ) ;
1735
1749
Raven . captureException ( error , { foo : 'bar' } ) ;
1736
1750
assert . isTrue ( window . handleStackInfo . calledOnce ) ;
1737
1751
} ) ;
1738
1752
1739
1753
it ( 'should store the last exception' , function ( ) {
1740
1754
var error = new Error ( 'crap' ) ;
1755
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1741
1756
this . sinon . stub ( window , 'handleStackInfo' ) ;
1742
1757
Raven . captureException ( error ) ;
1743
1758
assert . equal ( Raven . lastException ( ) , error ) ;
1744
1759
} ) ;
1745
1760
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 ( ) {
1747
1762
var error = new Error ( 'crap' ) ;
1763
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1748
1764
this . sinon . stub ( window , 'handleStackInfo' ) . throws ( error ) ;
1749
1765
// this would raise if the errors didn't match
1750
1766
Raven . captureException ( error , { foo : 'bar' } ) ;
@@ -1753,22 +1769,33 @@ describe('Raven (public API)', function() {
1753
1769
1754
1770
it ( 'should reraise a different error' , function ( ) {
1755
1771
var error = new Error ( 'crap1' ) ;
1772
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1756
1773
this . sinon . stub ( window , 'handleStackInfo' ) . throws ( error ) ;
1757
1774
assert . throws ( function ( ) {
1758
1775
Raven . captureException ( new Error ( 'crap2' ) ) ;
1759
1776
} , error ) ;
1760
1777
} ) ;
1761
1778
1762
1779
it ( 'should capture as a normal message if a non-Error is passed' , function ( ) {
1780
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1763
1781
this . sinon . stub ( Raven , 'captureMessage' ) ;
1764
1782
this . sinon . stub ( window , 'handleStackInfo' )
1765
1783
Raven . captureException ( 'derp' ) ;
1784
+ assert . isTrue ( Raven . captureMessage . called ) ;
1766
1785
assert . equal ( Raven . captureMessage . lastCall . args [ 0 ] , 'derp' ) ;
1767
1786
assert . isFalse ( window . handleStackInfo . called ) ;
1768
1787
Raven . captureException ( true ) ;
1788
+ assert . isTrue ( Raven . captureMessage . called ) ;
1769
1789
assert . equal ( Raven . captureMessage . lastCall . args [ 0 ] , true ) ;
1770
1790
assert . isFalse ( window . handleStackInfo . called ) ;
1771
1791
} ) ;
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
+ } ) ;
1772
1799
} ) ;
1773
1800
1774
1801
describe ( '.isSetup' , function ( ) {
0 commit comments