问题描述
it 'computes correctly when on & off have a list at cronRange[4]', ->
@component.set('cronRanges', [Ember.Object.create({
on: "* * * 3 3,1,5"
off: "* * * 3 3,1,5"
})])
@component.set('dayOfWeek', 2)
expect(@component.get('inRange')).to.be.false
@component.set('dayOfWeek', 5)
expect(@component.get('inRange')).to.be.true
@component.set('dayOfWeek', 1)
expect(@component.get('inRange')).to.be.true
@component.set('dayOfWeek', 3)
expect(@component.get('inRange')).to.be.true
这是炭烬单元测试,但由于错误是该问题的标题。
this is an ember unit test that fails with the error that is the is the title of this question.
推荐答案
如果您使用的是Ember,请尝试将异步调用包装在Ember.run =>
If you're using Ember, try wrapping async calls in Ember.run => read this
我了解的是,如果您在单元测试中将 @set(..,..)
设置为 @store()
,并收到此错误,则应使用 Ember.run =>
What I understood is, if you're setting something @set(..,..)
to the @store()
, in the unit tests, and get this error, then you should use Ember.run =>
此外,请记住箭头成为粗箭头,(我曾经使用->
而不是 =>
犯了这个错误),由于JavaScript的范围,如果您有兴趣,请继续阅读。
Also, remember the arrow has to be a fat arrow, (i made that mistake once of using ->
instead of =>
)it's because of javascript scope, read up on it if you are interested.
解决方案:请注意,我刚刚添加了第2行
Solution: observe that I just added line # 2
it 'computes correctly when on & off have a list at cronRange[4]', ->
Ember.run =>
@component.set('cronRanges', [Ember.Object.create({
on: "* * * 3 3,1,5"
off: "* * * 3 3,1,5"
})])
@component.set('dayOfWeek', 2)
expect(@component.get('inRange')).to.be.false
@component.set('dayOfWeek', 5)
expect(@component.get('inRange')).to.be.true
@component.set('dayOfWeek', 1)
expect(@component.get('inRange')).to.be.true
@component.set('dayOfWeek', 3)
expect(@component.get('inRange')).to.be.true
这篇关于确保此测试中调用了done()回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!