@@ -54,9 +54,14 @@ describe('Dataloader class', () => {
5454 notifyChanges,
5555 } )
5656 expect ( method ) . toBeCalledTimes ( 0 )
57- instance . load ( ) . catch ( undefined )
58- instance . load ( ) . catch ( undefined )
59- await instance . load ( )
57+
58+ // simulate multiple call in //
59+ await Promise . all ( [
60+ instance . load ( ) . catch ( undefined ) ,
61+ instance . load ( ) . catch ( undefined ) ,
62+ instance . load ( ) ,
63+ ] )
64+
6065 expect ( method ) . toBeCalledTimes ( 1 )
6166 instance . clearData ( )
6267 } )
@@ -71,7 +76,9 @@ describe('Dataloader class', () => {
7176 } )
7277 expect ( instance . getData ( ) ) . toBe ( undefined )
7378 expect ( notify ) . toBeCalledTimes ( 0 )
74- instance . load ( ) . catch ( undefined )
79+
80+ instance . load ( ) . catch ( ( ) => null )
81+
7582 expect ( method ) . toBeCalledTimes ( 1 )
7683 instance . cancel ( )
7784 expect ( notify ) . toBeCalledTimes ( 0 )
@@ -145,7 +152,9 @@ describe('Dataloader class', () => {
145152 method,
146153 notifyChanges,
147154 } )
155+
148156 instance . load ( ) . catch ( undefined )
157+
149158 instance . cancel ( )
150159 await waitForExpect ( ( ) => expect ( instance . status ) . toBe ( StatusEnum . IDLE ) )
151160 expect ( notifyChanges ) . toBeCalledTimes ( 1 )
@@ -181,9 +190,11 @@ describe('Dataloader class', () => {
181190 notifyChanges,
182191 } ) ,
183192 )
184- instances . forEach ( instance => {
185- instance . load ( ) . catch ( undefined )
186- } )
193+
194+ for await ( const instance of instances ) {
195+ await instance . load ( ) . catch ( ( ) => null )
196+ }
197+
187198 await waitForExpect ( ( ) => expect ( method ) . toBeCalledTimes ( 5 ) )
188199 } )
189200} )
0 commit comments