I'm having trouble acceptance testing an Ember CLI Component that uses ic-ajax to submit a form.
The problem is that the andThen function in the acceptance test doesn't wait for the form submission to resolve.
Component:
import Ember from 'ember';
import ajax from 'ic-ajax';
export default Ember.Component.extend({
tagName: 'form',
// ...snip...
submit(e) {
e.preventDefault();
const request = ajax({
url: "url.com"
});
// Debugging in test mode, Ember.Test.lastPromise === null here?
}
// ...snip...
});
Acceptance Test:
test('it surfaces errors', function(assert) {
visit('/test');
let component;
andThen(function() {
component = find('.my-form');
fillIn('input[Placeholder="Email"]', 'not@valid');
click('button[type="submit"]');
andThen(function() {
// PROBLEM: This code doesn't wait for the ic-ajax promise to resolve
assert.ok(component.hasClass('error'), "The component applied the error classname.");
});
});
});
Creating the ic-ajax promise doesn't seem to set Ember.Test.lastPromise, meaning andThen doesn't wait for the form submit to return.
Am I missing something here?
Aucun commentaire:
Enregistrer un commentaire