Asynchronous 在连续Ember.run.later期间单击验收测试
在控制器中,我有Asynchronous 在连续Ember.run.later期间单击验收测试,asynchronous,ember.js,automated-tests,acceptance-testing,Asynchronous,Ember.js,Automated Tests,Acceptance Testing,在控制器中,我有Ember.run.later循环,它不断更新计时器 run: function() { const lastResumeTimestamp = this.get("lastResumeTimestamp"); this.clearTimer(); this.set('timerId', Ember.run.later(this, function() { // update the timer // ... this.ru
Ember.run.later
循环,它不断更新计时器
run: function() {
const lastResumeTimestamp = this.get("lastResumeTimestamp");
this.clearTimer();
this.set('timerId', Ember.run.later(this, function() {
// update the timer
// ...
this.run();
}, 100));
},
在验收测试中,我要单击按钮,该按钮应暂停此循环:
test('I want to start/pause new activity', function(assert) {
visit('/');
andThen(function() {
assert.equal(find('.duration', activityBuilderSelector).text(), "0");
click('.start-activity-button', activityBuilderSelector);
// -->> start continuous Ember.run.later.loop, see: application cortroller
waitFor(assert, function() {
const val = find('.duration', activityBuilderSelector).text()
assert.notEqual(val, "0", `notEqual 0 (${val})`);
assert.equal(find('.title', activityBuilderSelector).text(), "New activity", "there should be activity title");
// -->> here test waiting because of run.later loop
click('.pause-activity-button', activityBuilderSelector);
});
});
andThen(function() {
//click('.resume-activity-button', activityBuilderSelector);
});
});
但测试在单击之前暂停,并等待循环停止
如何在循环期间触发此单击并停止它以继续测试?
下面是一个小把戏来说明这个问题:
我刚刚发现,我可以通过不使用测试助手来做到这一点:
$(“.暂停活动按钮”,activityBuilderSelector)。单击()代码>
但我不确定这是正确的处理方式