I have the controller code:
$scope.$on('load', function (event) {
$scope.getData();
event.stopPropagation();
});
and the test code:
it('$on load', function(event) {
var controller=createController();
spyOn(scope, 'getData').andCallThrough();
spyOn(scope, "$on").andCallFake(function (event) {
expect(event).toEqual("load");
});
scope.$broadcast('load',event);
expect(scope.getData).toHaveBeenCalled();
expect(scope.$on).toHaveBeenCalled();
});
TypeError: event.stopPropagation is not a function
How can I define the event parameter in the call from the Unit test so that it won't fail?