99} from '../../../src' ;
1010import * as Utils from '@agile-ts/utils' ;
1111import { LogMock } from '../../helper/logMock' ;
12+ import waitForExpect from 'wait-for-expect' ;
1213
1314describe ( 'Runtime Tests' , ( ) => {
1415 let dummyAgile : Agile ;
@@ -111,8 +112,10 @@ describe('Runtime Tests', () => {
111112
112113 it (
113114 "should perform specified Job and all remaining Jobs in the 'jobQueue' " +
114- "and call 'updateSubscribers' if at least one performed Job needs to rerender" ,
115+ "and call 'updateSubscribers' in a setTimeout " +
116+ 'if at least one performed Job needs to rerender (config.bucket = true)' ,
115117 async ( ) => {
118+ runtime . agileInstance ( ) . config . bucket = true ;
116119 runtime . jobQueue . push ( dummyJob2 ) ;
117120 runtime . jobQueue . push ( dummyJob3 ) ;
118121
@@ -129,8 +132,23 @@ describe('Runtime Tests', () => {
129132 expect ( runtime . jobQueue ) . toStrictEqual ( [ ] ) ;
130133 expect ( runtime . jobsToRerender ) . toStrictEqual ( [ dummyJob1 , dummyJob2 ] ) ;
131134
132- // Sleep 5ms because updateSubscribers is called in a timeout
133- await new Promise ( ( resolve ) => setTimeout ( resolve , 5 ) ) ;
135+ // Because 'updateSubscribers' is called in a timeout
136+ await waitForExpect ( ( ) => {
137+ expect ( runtime . updateSubscribers ) . toHaveBeenCalledTimes ( 1 ) ;
138+ } ) ;
139+ }
140+ ) ;
141+
142+ it (
143+ "should perform specified Job and all remaining Jobs in the 'jobQueue' " +
144+ "and call 'updateSubscribers' " +
145+ 'if at least one performed Job needs to rerender (config.bucket = false)' ,
146+ async ( ) => {
147+ runtime . agileInstance ( ) . config . bucket = false ;
148+ runtime . jobQueue . push ( dummyJob2 ) ;
149+ runtime . jobQueue . push ( dummyJob3 ) ;
150+
151+ runtime . perform ( dummyJob1 ) ;
134152
135153 expect ( runtime . updateSubscribers ) . toHaveBeenCalledTimes ( 1 ) ;
136154 }
@@ -151,7 +169,8 @@ describe('Runtime Tests', () => {
151169
152170 it (
153171 "should perform specified Job and all remaining Jobs in the 'jobQueue' " +
154- "and shouldn't call 'updateSubscribes' if no performed Job needs to rerender" ,
172+ "and shouldn't call 'updateSubscribes' " +
173+ 'if no performed Job needs to rerender' ,
155174 async ( ) => {
156175 dummyJob1 . rerender = false ;
157176 runtime . jobQueue . push ( dummyJob3 ) ;
0 commit comments