¿Por qué no se llama a este espía sinon cuando ejecuto esta prueba?
Tengo un modelo de red troncal:
class DateTimeSelector extends Backbone.Model
initialize: ->
@bind 'change:date', @updateDatetime
@bind 'change:time', @updateDatetime
updateDatetime: =>
# do some stuff with the sate and time
Y tengo algunas pruebas para ese código usandojazmí y 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 que funciona cuando lo uso en el navegador, pero parece que no puedo pasar las pruebas. ¿Alguien puede iluminarme?