나는 재스민에서 기쁨을 얻지 못하고 있습니다 .Clock. 내 기대는 코드가 clock 객체를 조롱하고 setTimeout의 지정된 간격을 넘어선 진드기를 설정할 때 setTimeout 이벤트를 트리거하지만, 이것이 작동하지 않는 것으로 보이고 내 결함을 찾을 수 없다는 것이다. 내 코드는 다른 클럭 컨트롤 동작을 적용하는 다른 사람들과 병렬로 보인다.jasmine coffeescript 시계가 효과적이지 않습니다.
배경 : 'callback'함수는 실행 후 this.action.state()를 Constants.state.Ready로 설정하고, 그 전에 Constants.state.WAITING이어야합니다. 내가 녹아웃 관찰을 사용하고 있습니다. 상태는 값을 검색하기 위해 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)
결과 : 실패 : jasmine.Clock.defaultFakeTimer.setTimeout의
1) should initialize with public accessible state of waiting
Message:
Expected 'ready' to equal 'waiting'.
Stacktrace:
Error: Expected 'ready' to equal 'waiting'.