@@ -841,6 +841,28 @@ describe('globals', function() {
841
841
} ) ;
842
842
} ) ;
843
843
844
+ it ( 'should respect `globalOptions.sampleRate` to omit event' , function ( ) {
845
+ Raven . _globalOptions . sampleRate = 0.5 ;
846
+ this . sinon . stub ( Math , 'random' ) . returns ( 0.8 ) ;
847
+ this . sinon . stub ( Raven , '_sendProcessedPayload' ) ;
848
+ Raven . _send ( { message : 'bar' } ) ;
849
+ assert . isFalse ( Raven . _sendProcessedPayload . called ) ;
850
+ } ) ;
851
+
852
+ it ( 'should respect `globalOptions.sampleRate` to include event' , function ( ) {
853
+ Raven . _globalOptions . sampleRate = 0.5 ;
854
+ this . sinon . stub ( Math , 'random' ) . returns ( 0.3 ) ;
855
+ this . sinon . stub ( Raven , '_sendProcessedPayload' ) ;
856
+ Raven . _send ( { message : 'bar' } ) ;
857
+ assert . isTrue ( Raven . _sendProcessedPayload . called ) ;
858
+ } ) ;
859
+
860
+ it ( 'should always send if `globalOptions.sampleRate` is omitted' , function ( ) {
861
+ this . sinon . stub ( Raven , '_makeRequest' ) ;
862
+ Raven . _send ( { message : 'bar' } ) ;
863
+ assert . isTrue ( Raven . _makeRequest . called ) ;
864
+ } ) ;
865
+
844
866
it ( 'should strip empty tags' , function ( ) {
845
867
this . sinon . stub ( Raven , 'isSetup' ) . returns ( true ) ;
846
868
this . sinon . stub ( Raven , '_makeRequest' ) ;
0 commit comments