我没有从我的茉莉花中得到快乐。时钟。我的期望是代码将模拟时钟对象并在将滴答设置超过 setTimeout 中的指定间隔时触发 setTimeout 事件,但这似乎不起作用,我找不到我的缺陷。我的代码似乎与其他应用相同时钟控制行为的代码平行。
背景:“回调”函数在执行后将 this.action.state() 设置为 Constants.state.Ready,之前它应该是 Constants.state.WAITING。请注意,我使用的是淘汰赛 observables;该状态应该被称为 fx 以检索值。
describe "Redis GET Action", () ->
beforeEach () ->
jasmine.Clock.useMock();
this.getReturnValue = getReturnValue = "Some jasmine values from redis"
clientStub =
get: (key,callback) ->
if callback?
setTimeout(callback(undefined, getReturnValue),1500)
GET: (key,callback) ->
if callback?
setTimeout(callback(undefined, getReturnValue),1500)
this.action = new RedisGetAction(
client: clientStub
key: "Standard"
)
it "should return a object", () ->
expect(this.action).toEqual(jasmine.any(Object))
requiredMethods = ['state','data','params'];
requiredMethods.forEach (methodName) ->
it "should have public "+methodName+" method", () ->
expect(this.action[methodName]).toBeDefined();
it "should initialize with public accessible state of #{Constants.state.WAITING}", () ->
expect(this.action.state()).toEqual(Constants.state.WAITING)
jasmine.Clock.tick(1501);
expect(this.action.state()).toEqual(Constants.state.READY)
结果: 失败:
1) should initialize with public accessible state of waiting
Message:
Expected 'ready' to equal 'waiting'.
Stacktrace:
Error: Expected 'ready' to equal 'waiting'.