// should not be called
expect(spy).toHaveBeenCalledTimes(0)
})
+
+ it('flushPreFlushCbs inside a pre job', async () => {
+ const spy = jest.fn()
+ const job = () => {
+ spy()
+ flushPreFlushCbs()
+ }
+ job.pre = true
+ queueJob(job)
+ await nextTick()
+ expect(spy).toHaveBeenCalledTimes(1)
+ })
})
queueFlush()
}
-export function flushPreFlushCbs(seen?: CountMap, i = flushIndex) {
+export function flushPreFlushCbs(
+ seen?: CountMap,
+ // if currently flushing, skip the current job itself
+ i = isFlushing ? flushIndex + 1 : 0
+) {
if (__DEV__) {
seen = seen || new Map()
}