@@ -54,48 +54,6 @@ describe('Bulk Operation Buffer', () => {
5454 expect ( bulkUpdate ) . toHaveBeenCalledWith ( [ task1 , task2 ] ) ;
5555 } ) ;
5656
57- test ( 'batch updates are executed at most by the next Event Loop tick by default' , async ( ) => {
58- const bulkUpdate : jest . Mocked < BulkOperation < TaskInstance , Error > > = jest . fn ( ( tasks ) => {
59- return Promise . resolve ( tasks . map ( incrementAttempts ) ) ;
60- } ) ;
61-
62- const bufferedUpdate = createBuffer ( bulkUpdate ) ;
63-
64- const task1 = createTask ( ) ;
65- const task2 = createTask ( ) ;
66- const task3 = createTask ( ) ;
67- const task4 = createTask ( ) ;
68- const task5 = createTask ( ) ;
69- const task6 = createTask ( ) ;
70-
71- return new Promise ( ( resolve ) => {
72- Promise . all ( [ bufferedUpdate ( task1 ) , bufferedUpdate ( task2 ) ] ) . then ( ( _ ) => {
73- expect ( bulkUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
74- expect ( bulkUpdate ) . toHaveBeenCalledWith ( [ task1 , task2 ] ) ;
75- expect ( bulkUpdate ) . not . toHaveBeenCalledWith ( [ task3 , task4 ] ) ;
76- } ) ;
77-
78- setTimeout ( ( ) => {
79- // on next tick
80- setTimeout ( ( ) => {
81- // on next tick
82- expect ( bulkUpdate ) . toHaveBeenCalledTimes ( 2 ) ;
83- Promise . all ( [ bufferedUpdate ( task5 ) , bufferedUpdate ( task6 ) ] ) . then ( ( _ ) => {
84- expect ( bulkUpdate ) . toHaveBeenCalledTimes ( 3 ) ;
85- expect ( bulkUpdate ) . toHaveBeenCalledWith ( [ task5 , task6 ] ) ;
86- resolve ( ) ;
87- } ) ;
88- } , 0 ) ;
89-
90- expect ( bulkUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
91- Promise . all ( [ bufferedUpdate ( task3 ) , bufferedUpdate ( task4 ) ] ) . then ( ( _ ) => {
92- expect ( bulkUpdate ) . toHaveBeenCalledTimes ( 2 ) ;
93- expect ( bulkUpdate ) . toHaveBeenCalledWith ( [ task3 , task4 ] ) ;
94- } ) ;
95- } , 0 ) ;
96- } ) ;
97- } ) ;
98-
9957 test ( 'batch updates can be customised to execute after a certain period' , async ( ) => {
10058 const bulkUpdate : jest . Mocked < BulkOperation < TaskInstance , Error > > = jest . fn ( ( tasks ) => {
10159 return Promise . resolve ( tasks . map ( incrementAttempts ) ) ;
0 commit comments