mardi 29 novembre 2016

How to assert dom change in ember app which has been executed in run loop?

I am writing test for ember app written in ember 1.6.

Inside controller I have a function executed on promise success:

var me = this;

function onSuccess(result) {

    printSuccessMessage();

    Ember.RSVP.all(promises).then(function(value) {
        Ember.run.later(this, function() {
            clearMessages();
        }, 5000);
    });
}

then inside test I am trying to assert that success message appears:

    fillIn('#MyInputField', 'Some text');
    click('#MyButton');

    andThen(function() {
        strictEqual(find('[data-output="info-message"]').text().trim().indexOf('Done!') >= 0, true, 'Expected success message!');
    });

But the problem is that after click andThen is waiting for run loop to empty. So after this click andThen waits 5 seconds and then execute assertions. In that moment clearMessages() is already executed and message div is cleared so test fails.

Any idea how to assert that this message has certain text?

Aucun commentaire:

Enregistrer un commentaire