Hi,
I have some code that executes in steps using $timeout without a delay. However, when I do $timeout.flush() in my test, all timeout functions are flushed, including the new ones that are added/scheduled while flushing. This makes it impossible for me to test that there are multiple timeouts, as opposed to there being a single timeout and then everything happening in one go.
The following fiddle illustrates the problem:
After the first flush, I expect the first timeout function to have been executed, but I want to defer executing the second one until I flush again.
The only workaround I've found so far is to specify a delay for the second timeout function. I chose 4 ms since that is the minimum delay for current browsers anyway. And that brings me to another thing - shouldn't $timeout.flush() assume that if a timeout has been added without delay, it has a delay of 4 ms?
Cheers,
Per