Why is this sinon spy not being called when I run this test?

前端 未结 2 718
盖世英雄少女心
盖世英雄少女心 2020-12-02 15:44

I have a Backbone Model:

class DateTimeSelector extends Backbone.Model

  initialize: ->
    @bind \'change:date\', @updateDatetime
    @bind \'change:tim         


        
2条回答
  •  悲哀的现实
    2020-12-02 16:27

    You're mixing the mocking syntax of jasmine and sinon together.

    In your passing test your sinon spy exposes the property calledOnce but you're using a jasmine-esque function toHaveBeenCalledOnce(). This function doesn't exist on the sinon spy so essentially no assert is taking place.

    In your failing tests you're calling the jasmine spy function toHaveBeenCalled() on your sinon spy. Jasmine has its own syntax for creating a spy: spyOn(obj, 'method');

提交回复
热议问题