Por que esse espião sinon não está sendo chamado quando eu executo este teste?
Tenho um modelo de backbone:
class DateTimeSelector extends Backbone.Model
initialize: ->
@bind 'change:date', @updateDatetime
@bind 'change:time', @updateDatetime
updateDatetime: =>
# do some stuff with the sate and time
E eu tenho alguns testes para esse código usandojasmi e sinon.js
describe "DateTimeSelector", ->
beforeEach ->
@datetime = new DateTimeSelector()
describe "updateDatetime", ->
beforeEach ->
@updateSpy = sinon.spy(@datetime, 'updateDatetime')
afterEach ->
@datetime.updateDatetime.restore()
# passes
it "should be called when we call it", ->
@datetime.updateDatetime()
expect(@updateSpy).toHaveBeenCalledOnce()
# fails
it "should be called when we trigger it", ->
@datetime.trigger 'change:date'
expect(@updateSpy).toHaveBeenCalled()
# fails
it "should be called when we set the date", ->
@datetime.set { date: new Date() }
expect(@updateSpy).toHaveBeenCalled()
Parece funcionar quando o uso no navegador, mas não consigo passar nos testes. Alguém pode me esclarecer?