@@ -746,8 +746,8 @@ describe('Collector', function () {
746746 } )
747747 } )
748748
749- describe ( 'Sampling ' , function ( ) {
750- it ( 'happens when there is a big amount of data #1' , function ( ) {
749+ describe ( 'Sampler ' , function ( ) {
750+ it ( 'samples big amount of data #1' , function ( ) {
751751 this . sandbox . stub ( microtime , 'now' , function ( ) {
752752 return 2
753753 } )
@@ -780,7 +780,7 @@ describe('Collector', function () {
780780 expect ( length ) . to . be . above ( 0 )
781781 } )
782782
783- it ( 'happens when there is a big amount of data #2' , function ( ) {
783+ it ( 'happens big amount of data #2' , function ( ) {
784784 this . sandbox . stub ( microtime , 'now' , function ( ) {
785785 return 2
786786 } )
@@ -802,5 +802,30 @@ describe('Collector', function () {
802802 expect ( length ) . to . be . below ( 50 )
803803 expect ( length ) . to . be . above ( 0 )
804804 } )
805+
806+ it ( 'is emptied' , function ( ) {
807+ this . sandbox . stub ( microtime , 'now' , function ( ) {
808+ return 2
809+ } )
810+ var tracer = new Collector ( assign ( { samplerLimit : 10 } , options ) )
811+ function report ( ) {
812+ var cs = {
813+ payload : { severity : tracer . mustCollectSeverity } ,
814+ briefcase : { }
815+ }
816+ var csResult = tracer . clientSend ( cs . payload , cs . briefcase )
817+
818+ var cr = {
819+ payload : { }
820+ }
821+ tracer . clientRecv ( cr . payload , { } , csResult . briefcase )
822+ }
823+ for ( var i = 0 ; i < 50 ; ++ i ) { report ( ) }
824+ var length = tracer . collect ( ) . length
825+ expect ( length ) . to . be . below ( 50 )
826+ expect ( length ) . to . be . above ( 0 )
827+
828+ expect ( tracer . _sampler . size ( ) ) . to . equal ( 0 )
829+ } )
805830 } )
806831} )
0 commit comments