@@ -280,10 +280,11 @@ describe('raven.Client', function () {
280
280
} ) ;
281
281
282
282
afterEach ( function ( ) {
283
+ process . removeAllListeners ( 'uncaughtException' ) ;
283
284
var uncaughtBefore = this . uncaughtBefore ;
284
285
// restore things to how they were
285
286
for ( var i = 0 ; i < uncaughtBefore . length ; i ++ ) {
286
- process . addListener ( 'uncaughtException' , uncaughtBefore [ i ] ) ;
287
+ process . on ( 'uncaughtException' , uncaughtBefore [ i ] ) ;
287
288
}
288
289
} ) ;
289
290
@@ -400,6 +401,80 @@ describe('raven.Client', function () {
400
401
} ) ;
401
402
} ) ;
402
403
404
+ it ( 'should pass original shouldSendCallback to newer shouldSendCallback' , function ( done ) {
405
+ var cb1 = function ( data ) {
406
+ return false ;
407
+ } ;
408
+
409
+ var cb2 = function ( data , original ) {
410
+ original . should . equal ( cb1 ) ;
411
+ return original ( data ) ;
412
+ } ;
413
+
414
+ var cb3 = function ( data , original ) {
415
+ return original ( data ) ;
416
+ } ;
417
+
418
+ client = new raven . Client ( dsn , {
419
+ shouldSendCallback : cb1 ,
420
+ } ) ;
421
+
422
+ client . setShouldSendCallback ( cb2 ) ;
423
+ client . setShouldSendCallback ( cb3 ) ;
424
+
425
+ // neither of these should fire, so report err to done if they do
426
+ client . on ( 'logged' , done ) ;
427
+ client . on ( 'error' , done ) ;
428
+
429
+ client . process ( {
430
+ message : 'test'
431
+ } , function ( err , eventId ) {
432
+ setTimeout ( done , 10 ) ;
433
+ } ) ;
434
+ } ) ;
435
+
436
+ it ( 'should pass original dataCallback to newer dataCallback' , function ( done ) {
437
+ var scope = nock ( 'https://app.getsentry.com' )
438
+ . filteringRequestBody ( / .* / , '*' )
439
+ . post ( '/api/269/store/' , '*' )
440
+ . reply ( 200 , function ( uri , body , cb ) {
441
+ zlib . inflate ( new Buffer ( body , 'base64' ) , function ( err , dec ) {
442
+ if ( err ) return done ( err ) ;
443
+ var msg = JSON . parse ( dec . toString ( ) ) ;
444
+ msg . extra . foo . should . equal ( 'bar' ) ;
445
+ cb ( null , 'OK' ) ;
446
+ } ) ;
447
+ } ) ;
448
+
449
+ var cb1 = function ( data ) {
450
+ data . extra = { foo : 'bar' } ;
451
+ return data ;
452
+ } ;
453
+
454
+ var cb2 = function ( data , original ) {
455
+ original . should . equal ( cb1 ) ;
456
+ return original ( data ) ;
457
+ } ;
458
+
459
+ var cb3 = function ( data , original ) {
460
+ return original ( data ) ;
461
+ } ;
462
+
463
+ client = new raven . Client ( dsn , {
464
+ dataCallback : cb1 ,
465
+ } ) ;
466
+
467
+ client . setDataCallback ( cb2 ) ;
468
+ client . setDataCallback ( cb3 ) ;
469
+
470
+ client . process ( {
471
+ message : 'test'
472
+ } , function ( err , eventId ) {
473
+ scope . done ( ) ;
474
+ done ( ) ;
475
+ } ) ;
476
+ } ) ;
477
+
403
478
it ( 'should call the callback after sending' , function ( done ) {
404
479
var firedCallback = false ;
405
480
var sentResponse = false ;
0 commit comments