It's my first test on Javacript with Mocha/Sinon/Chai And I don't know if it's possible to do this :
var obj = {
first : function () {
console.log('make job 1');
}
};
var objManager = function() {
$(document).on('event1', obj.first);
};
new objManager();
var spy = sinon.spy(obj, 'first');
describe('Test', function () {
it('My first test', function () {
$(document).trigger('event1');
spy.should.not.have.been.called;
});
});
My spy isn't called and don't understand why... My function "obj.first" has printed "make job 1".
if I modify my test by :
it('My first test', function () {
obj.first();
spy.should.not.have.been.called;
});
My spy is called. So my question is : How make sinon spy work with a event ?