The issue lies in the fact that when you use this.clock.tick(1000);
, it doesn't actually make your test code pause for 1000ms. Instead, it triggers all JavaScript setTimeouts
that are set to occur during that time. This means that if you're starting an animation, using this.clock.tick(1000);
won't have any effect because the animation will still take 1000ms to complete. What you're seeking is something similar to Jasmine's waits()
, which halts the execution of test code below it for a specified amount of time. Unfortunately, QUnit and Sinon don't seem to have an equivalent feature.
By the way, what you're attempting seems more like an acceptance test than a unit test. Consider mocking your DOM element so that you can simulate triggering the transitionEnd event in your test instead of running a real animation. Running an actual animation and waiting for it to finish could result in significantly longer unit tests. For example, in my most recent project, we have around 200 test cases that each take 1-2 seconds to run. Imagine how much time this would add up to if we started introducing waits
into our tests.