Reputation: 2092
I am testing a piece of code where I want to specifically test that a certain event is never triggered.
eventBus.once("property:change", function(msg) {
expect(true).to.eq(false);
done();
});
Instead of 'expect(true).to.eq(false);' or 'done(new Error("should have never been reached"));' is there a way to say
fail("should have never been reached"):
The latter would be much more expressive. Is there a statement/solution like this, couldn't find any.
Upvotes: 3
Views: 50
Reputation: 8174
I would use a spy - http://sinonjs.org/
var callback = sinon.spy();
eventBus.once("property:change", callback);
// Things that could potentially but should not trigger the event
assert.equals(callback.callCount, 0);
Upvotes: 3