@@ -4051,22 +4051,30 @@ describe('AmplitudeClient', function () {
40514051
40524052 it ( 'should use sendBeacon when beacon transport is set' , function ( ) {
40534053 sandbox . stub ( navigator , 'sendBeacon' ) . returns ( true ) ;
4054+ const callback = sandbox . spy ( ) ;
4055+ const errCallback = sandbox . spy ( ) ;
40544056
40554057 amplitude . init ( apiKey , null , { transport : constants . TRANSPORT_BEACON } ) ;
4056- amplitude . logEvent ( 'test event' ) ;
4058+ amplitude . logEvent ( 'test event' , { } , callback , errCallback ) ;
40574059
40584060 assert . equal ( navigator . sendBeacon . callCount , 1 ) ;
40594061 assert . equal ( amplitude . _unsentEvents . length , 0 ) ;
4062+ assert . isTrue ( callback . calledOnce ) ;
4063+ assert . isFalse ( errCallback . calledOnce ) ;
40604064 } ) ;
40614065
40624066 it ( 'should not remove event from unsentEvents if beacon returns false' , function ( ) {
40634067 sandbox . stub ( navigator , 'sendBeacon' ) . returns ( false ) ;
4068+ const callback = sandbox . spy ( ) ;
4069+ const errCallback = sandbox . spy ( ) ;
40644070
40654071 amplitude . init ( apiKey , null , { transport : constants . TRANSPORT_BEACON } ) ;
4066- amplitude . logEvent ( 'test event' ) ;
4072+ amplitude . logEvent ( 'test event' , { } , callback , errCallback ) ;
40674073
40684074 assert . equal ( navigator . sendBeacon . callCount , 1 ) ;
40694075 assert . equal ( amplitude . _unsentEvents . length , 1 ) ;
4076+ assert . isFalse ( callback . calledOnce ) ;
4077+ assert . isTrue ( errCallback . calledOnce ) ;
40704078 } ) ;
40714079 } ) ;
40724080} ) ;
0 commit comments