I've been successful writing unit level tests in ember w/ help from the sinon clock but acceptance tests always seem to be an issue.
For example, in my route I intend to wait 5 seconds before I do something
export default Ember.Route.extend({
model: function() {
setTimeout(Ember.run.bind(this, function() {
//after the timeout do something like transition to another route
}), 5000);
}
});
In ember testing I'd do a simple visit, assert the currentURL() is good, then do a clock.tick(5001) w/ sinon ... then assert the timer is complete and some state was set/etc.
I realize sinon and the ember run loop don't seem to play nice together but I'm curious what other people are using to test timers like this at the high level (non unit tests /without selenium or sleep hacks).
If run later is required how would you rework the (incorrect) test below to work with clock.tick ?
test("sinon and ember play nice", function(assert) {
var clock = sinon.useFakeTimers();
visit("/");
andThen(function() {
assert.equal(currentURL(), "/");
});
clock.tick(5001);
andThen(function() {
assert.equal(currentURL(), "/the-transition-url");
});
});