Let's say I have the following methods:
Controller.prototype.refresh = function () { console.log('refreshing'); } Controller.prototype.delete = function (object) { var self = this; object.delete({id: object.id}, function () { self.refresh(); }); }
now in my (mocha) test:
beforeEach(function () { var controller = new Controller(); var proto = controller.__proto__; var object = {id: 1, delete: function (options, callback) { callback (); }; sinon.stub(proto, 'refresh', function {console.log('refreshing stub')}); controller.delete(object); }); it('doesnt work', function () { expect(object.delete.callCount).to.equal(1); expect(proto.refresh.callCount).to.equal(1); });
This, however, prints an βupdateβ to the console. Is there a way to use synon to drown out a live prototype?
source share