I am covering this part of system with tests at the moment, I have events chained in a way that stopping propagation on first must cancel second event from firing.
$.fn.extend({
OnTheMoveBCTrigger: function (name, options) {
if (!(this[0] instanceof OnTheMove_BusinessComponent)) {
throw ('is not an instance of OnTheMove_BusinessComponent');
} else {
var event = $.Event(name);
var promise = $(this).OnTheMoveTrigger(event, options);
if (!event.isPropagationStopped()) {
$(onTheMove.PageDataRoles).OnTheMoveTrigger(name, options);
}
}
}
});
I figured how to check that second event was fired with jasmine-jquery spyOnEvent
it("OnTheMoveBCTrigger chain fires event on onTheMove.PageDataRoles", function () {
var spy = spyOnEvent(onTheMove.PageDataRoles, 'event2');
$(window.bc).OnTheMoveBCTrigger("event2");
expect('event2').toHaveBeenTriggeredOn(onTheMove.PageDataRoles);
expect(spy).toHaveBeenTriggered();
});
but now I need to test the case where propagation is being stopped and second event is not being fired.
How to check if event has not been fired?