jeudi 23 février 2017

Test the "loading" state in an Ember acceptance test

In my acceptance test, I want to confirm that the "loading indicator" is properly shown and hidden during an async action. Let's say I have an action that looks like this:

myAction() {
    this.set('isLoading', true);
    someAsyncMethod().then(answer => {
        this.set('isLoading', false);
    });
}

And a template that looks like this:

<button class="my-button" >
  
    <i class="loader"></i>
  
  Click me !
</button>

And finally, the test:

test('My super action', function(assert) {
    visit('/my-route');
    andThen(() => {
        click('.my-button');
        // Here, since the click() helper is async, the action isn't 
        // called, so the loader isn't shown yet.
    });
    andThen(() => {
      // Here, the load is finished, so the loader is removed
    });
});

My question is : Where can I do the assertion that the loader is shown ?




Aucun commentaire:

Enregistrer un commentaire