@@ -218,31 +218,32 @@ describe('globals', function() {
218218 it ( 'should return false when Raven is not configured' , function ( ) {
219219 hasJSON = true ; // be explicit
220220 globalServer = undefined ;
221- this . sinon . stub ( console , 'error ' ) ;
221+ this . sinon . stub ( window , 'logDebug ' ) ;
222222 assert . isFalse ( isSetup ( ) ) ;
223223 } ) ;
224224
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 ( ) ) ;
232228 } ) ;
229+ } ) ;
233230
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 ) ;
241240 } ) ;
242241
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 ) ;
246247 } ) ;
247248 } ) ;
248249
@@ -1168,6 +1169,15 @@ describe('Raven (public API)', function() {
11681169 assert . equal ( Raven . config ( '' ) , Raven ) ;
11691170 } ) ;
11701171
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+
11711181 describe ( 'whitelistUrls' , function ( ) {
11721182 it ( 'should be false if none are passed' , function ( ) {
11731183 Raven . config ( '//abc@example.com/2' ) ;
@@ -1237,6 +1247,14 @@ describe('Raven (public API)', function() {
12371247 assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
12381248 assert . equal ( TraceKit . report . subscribe . lastCall . args [ 0 ] , handleStackInfo ) ;
12391249 } ) ;
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+ } ) ;
12401258 } ) ;
12411259
12421260 describe ( '.wrap' , function ( ) {
@@ -1382,6 +1400,13 @@ describe('Raven (public API)', function() {
13821400 Raven . uninstall ( ) ;
13831401 assert . isTrue ( TraceKit . report . uninstall . calledOnce ) ;
13841402 } ) ;
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+ } ) ;
13851410 } ) ;
13861411
13871412 describe ( '.setUserContext' , function ( ) {
0 commit comments