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
这是一个失败的余烬单元测试,错误是这个问题的标题。
答案 0 :(得分:0)
如果您使用的是Ember,请尝试在Ember.run =>中包装异步调用。 read this
我理解的是,如果您在单元测试中将@set(..,..)
设置为@store()
并获得此错误,那么您应该使用Ember.run =>
此外,请记住箭头必须是一个胖箭头(我使用->
而不是=>
犯了一个错误)这是因为javascript范围,如果你感兴趣,请阅读它
解决方案:观察我刚刚添加第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