In my ember application, I use bootbox ( http://bootboxjs.com/ ) to confirm the removal of some models. In my qunit test, I press the button with {{action}}, in this action I open the boot box. In the text, I click OK on the boot box.
But the andThen method does not wait for the boot box to disappear. Therefore, checking if a model is deleted is always false. I tried to return a promise, but the assistant andThen also did not wait for promises.
Is there a way that allows testing to wait until the bootbox promise is resolved or the boot box callback is completed?
Additional information: My template:
<button class="btn btn-default" {{action 'askDelete' target="view"}} data-toggle="tooltip" data-placement="right" {{translateAttr title="trips.remove"}}><i class="fa fa-trash-o"></i></button>
My view:
actions: {
askDelete: function(){
var self = this;
self.$('td').slideUp('500').promise().then(function(){
self.get('controller').send('delete');
});
}
}
My controller:
actions: {
save: function(){
self.get('content').save().then(function(){
self.get('controllers.history').transitionToPrevious('trips.index');
});
My test:
click(".specific-row .action-buttons button");
andThen(function() {
ok(find(".content-row table tr:contains('content-of-row')").length === 0, "deleted and removed from the table");
});
ok , , false.
jsfiddle :
http://jsfiddle.net/21af9puz/1/