Hi all lovely people,
I have a reasonably special use-case: I have an input field which issues a search when the user has stopped typing for 500ms. This is developed as a reusable add-on. Nothing really fancy and it works fine with Ember.run.later
.
I would like to write an acceptance test for this but I cannot make the tests pass properly. The first passes, the second doesn’t.
Now, the Ember runloop has a nice description but it’s behaviour is really “something else”.
This is my helper to timeout the runloop:
import Ember from 'ember';
export default Ember.Test.registerAsyncHelper('pauseFor', function (time) {
return Ember.Test.promise(function (resolve) {
Ember.run.later(resolve, time);
});
});
And this is how I use it
it('should do something after 500ms', function () {
visit('/');
fillIn('.search-input', 'a');
pauseFor(500);
andThen(function () {
// do my assertions/expectations here...
});
});
I am not allowed to post new pics yet but the original question with the attached shot of the error can be found here: testing - Ember acceptance test - timeouts - Stack Overflow
The weird thing is that I have 2 test cases and the first passes happily.
I guess my question is: How to do this properly? What am I missing here or what am I doing wrong? How can I just simply timeout the test case?
Thanks for the halp in advance! =)