Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

`waitUntil` async helper feedback

$
0
0

@ppcano wrote:

I would like to get some feedback on the use of registerWaiter in an async helper to wait for animated components to appear.

In our acceptance tests, the waitUntil helper could be used as:

waitUntil('#my-button');

click('#my-button');

or

waitUntil('#my-modal.modal').then(function() {

  var el = find('#my-modal.modal');
  assert.ok(el.length > 0, 'modal was open');
  ....
});

Below the helper implementation:

Ember.Test.registerAsyncHelper('waitUntil', function(app, selector, callback) {

  var waiter = function() {
    return $(selector).length > 0;
  };

  Ember.Test.registerWaiter(waiter);
  var promise = app.testHelpers.wait();

  promise.then(function() {
    Ember.Test.unregisterWaiter(waiter);
  });

  // it will be resolved when the pending events have been processed
  // (routing loads, ajax requests, run loops and waiters)
  return promise;

});

I think, this could be a common use of registerWaiter which could be added to the documentation.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles