@@ -26,6 +26,7 @@ describe('LongResend', () => {
2626 let stream : Stream
2727 let expectErrors = 0 // check no errors by default
2828 let onError = jest . fn ( )
29+ let prevEnabled : boolean
2930
3031 const createClient = ( opts = { } ) => new StreamrClient ( {
3132 autoConnect : false ,
@@ -40,13 +41,26 @@ describe('LongResend', () => {
4041 }
4142 } )
4243 await client . connect ( )
44+ } )
45+
46+ beforeEach ( async ( ) => {
4347 expectErrors = 0
4448 onError = jest . fn ( )
4549 client . onError = jest . fn ( )
4650 client . on ( 'error' , onError )
4751 stream = await client . getStream ( TRAM_DEMO_STREAM )
4852 } )
4953
54+ beforeEach ( ( ) => {
55+ client . debug ( 'disabling logging for long tests' )
56+ prevEnabled = client . debug . enabled
57+ client . debug . enabled = false
58+ } )
59+
60+ afterEach ( ( ) => {
61+ client . debug . enabled = prevEnabled
62+ } )
63+
5064 afterEach ( async ( ) => {
5165 await wait ( 0 )
5266 // ensure no unexpected errors
@@ -70,38 +84,40 @@ describe('LongResend', () => {
7084 }
7185 } )
7286
73- const RESEND_SIZES = [
74- 1 ,
75- 10 ,
76- 20 ,
77- 100 ,
78- 1000 ,
79- 10000 ,
80- 25000 , // will be ignored, max is 10,000
81- ]
82-
83- const MAX_RESEND_SIZE = 10000
84-
85- RESEND_SIZES . forEach ( ( size ) => {
86- test . only ( `can get a resend of size ${ size } ` , async ( ) => {
87- const id = `TEST ${ size } `
88- let count = 0
89- const sub = await client . resend ( {
90- stream : stream . id ,
91- resend : {
92- last : size
93- } ,
94- } , ( ) => {
95- count += 1
96- } )
97- await sub . onDone ( )
98- client . debug ( id , { count } )
99- if ( size < MAX_RESEND_SIZE ) {
100- expect ( count ) . toBe ( size )
101- } else {
102- expect ( count ) . toBe ( 10000 )
103- }
104- } , Math . max ( 10000 , size ) )
87+ describe ( 'Resends of different sizes' , ( ) => {
88+ const RESEND_SIZES = [
89+ 1 ,
90+ 10 ,
91+ 20 ,
92+ 100 ,
93+ 1000 ,
94+ 10000 ,
95+ 25000 , // will be ignored, max is 10,000
96+ ]
97+
98+ const MAX_RESEND_SIZE = 10000
99+
100+ RESEND_SIZES . forEach ( ( size ) => {
101+ test ( `can get a resend of size ${ size } ` , async ( ) => {
102+ const id = `TEST ${ size } `
103+ let count = 0
104+ const sub = await client . resend ( {
105+ stream : stream . id ,
106+ resend : {
107+ last : size
108+ } ,
109+ } , ( ) => {
110+ count += 1
111+ } )
112+ await sub . onDone ( )
113+ client . debug ( id , { count } )
114+ if ( size < MAX_RESEND_SIZE ) {
115+ expect ( count ) . toBe ( size )
116+ } else {
117+ expect ( count ) . toBe ( 10000 )
118+ }
119+ } , Math . max ( 10000 , size ) * 2 )
120+ } )
105121 } )
106122
107123 describe ( 'large number of messages' , ( ) => {
0 commit comments