1

I have the following test suite:

describe('rendering Bundle View', function () {
    beforeEach(function () {
        this.view = new Backbone.View();
        this.renderStub = Sinon.stub(this.view, 'render', function () {
            this.el = document.createElement('div');
            return this;
        });
        this.view.render();
    });
    it('should have called render once', function () {
        console.info('RENDERRRR' + (typeof this.renderStub));
        expect(this.renderStub.calledOnce).toBe(true); // this passes
        expect(this.renderStub).toHaveBeenCalled(); // this fails
    });
});

Why does the first expect statement pass but the second fail? The second gives the error message: expected Spy but got Function even though Sinon stubs implement the spy API so it should return a spy??

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
gofishus
  • 11
  • 4
  • 3
    You should actually submit an answer to your question or delete it so that people who want to help don't come here for nothing. – Louis Dec 03 '13 at 19:36

1 Answers1

0

figured it out. I think its because I was using a Sinon spy with a jasmine function that expected a jasmine spy hence it didn't allow me to use Sinon expect statements

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265