I'm developing an Ember-based application with front-end integration testing using QUnit and Teaspoon. I'm currently trying to implement a new feature that involves regular server queries using recursive calls of Ember.run.later
. In much simplified form, written in CoffeeScript, this code is:
App.Widget = DS.Model.extend
...
update: ->
widget = @
options = {...}
@store.findQuery('widget_children', options).then (data) ->
(do stuff with data)
Ember.run.later widget, widget.update, 10000
I then have a set of unrelated tests that involve clicking on various elements of the page (using the click
helper in Ember.Test
), similar to the following:
asyncTest 'Gadget modal displays on link click', 1, ->
Ember.run ->
click($('.gadget a')).then ->
start()
equal $('#gadget-modal').length, 1, "Gadget modal not present"
What I'm seeing right now is that when Teaspoon gets to a click test (with a later
call pending due to the app setup), it performs the click correctly, but the promise never resolves and the actual test assertions are not tested.
I'm assuming that the promise is not resolving because the deferred later
call is considered asynchronous behaviour that the click
helper is waiting to be completed, except that when it completes it merely sets up another later
call – so it is never resolved.
Is there a way around this?