在我的Ember应用程序中,我使用bootbox(http://bootboxjs.com/)来确认删除某些模型。
在我的qunit测试中,我通过{{ action }}点击按钮,在此操作中打开一个bootbox。
在文本中,我单击bootbox上的OK按钮。
但是,andThen方法不会等待bootbox消失。因此,检查模型是否已删除始终为false。我尝试返回promise,但是andThen助手也不等待promise。
有没有办法让测试等待bootbox的promise被解决,或者等待bootbox的回调完成?
额外信息: 我的模板是:
我的观点是:
但是最新的ok在控制器中的保存操作之前被调用,因此始终为false。我已经创建了一个jsfiddle,其中包含一个最简情况: http://jsfiddle.net/21af9puz/1/。
但是,andThen方法不会等待bootbox消失。因此,检查模型是否已删除始终为false。我尝试返回promise,但是andThen助手也不等待promise。
有没有办法让测试等待bootbox的promise被解决,或者等待bootbox的回调完成?
额外信息: 我的模板是:
<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>
我的观点是:
actions: {
askDelete: function(){
var self = this;
self.$('td').slideUp('500').promise().then(function(){
self.get('controller').send('delete');
});
}
}
我的控制器:
actions: {
save: function(){
self.get('content').save().then(function(){
self.get('controllers.history').transitionToPrevious('trips.index');
});
我的测试:
click(".specific-row .action-buttons button");
andThen(function() {
// Check if the row is indeed removed from the table
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/。