I need to test that events get correctly emitted or broadcast, and trigger events manually.
What\'s the best way to do this?
Here are the steps you should follow to $broadcast event in angular JS
While inijecting initialize the rootScope and scope stub as given below:
var rootScope;
var scopeStub = beforeEach(function() {
inject(function($rootScope, _$controller_) {
rootScope = $rootScope;
scopeStub = $rootScope.$new();
$controller = _$controller_;
});
});
After controller is created raise event using rootScope like below:
rootScope.$broadcast('eventName', parameter1);