Currently, I am utilizing SinonJS to verify that my controller is calling certain methods within my view. Specifically, I am aiming to confirm that the addSeat
method is invoked with the value of testSeat
. Despite my efforts in the code snippet below, I am encountering an error. I am seeking a way to conduct this test without needing to incorporate my view module into the testing process. Is there a way to achieve this?
describe('Adding a seat', function() {
view1Spy = {
addSeat: sinon.spy(),
render: sinon.spy()
};
beforeEach(function() {
newSeat = seatingChartController.addSeat(3, 4);
seatingChartController.registerView(view1Spy);
});
it('Calls addSeat on each view with the added seat', function() {
expect(view1Spy.addSeat).to.be.calledWith(newSeat);
});
}
UPDATE:
Here is the specific error message that I am encountering:
1) Seating Chart Controller Adding a seat Calls addSeat on each view with the added seat
Failure/Error: 'undefined' is not a function (evaluating 'expect(view1Spy.addSeat).to.be.calledWith(newSeat)'