How to catch $broadcast in spyOn?
<p>I don't know why my testing is not working.</p>

<pre><code>it('should be called when "get-tentative-events" is fired', function() {
  spyOn(this.VM, 'addEvents');
  spyOn(this.VM, 'setEventData').and.returnValue(null);

  this.VM.$root.$broadcast('get-tentative-events', []);
  expect(this.VM.addEvents).toBeDefined();
  expect(this.VM.addEvents).toHaveBeenCalled();
});
</code></pre>

<p>In debugging, I confirmed <code>addEvents</code> is called.<br>
But there was a error <code>single-calendar addEvents should be called when "get-tentative-events" is fired FAILED</code></p>

<p>FYI:</p>

<p>if I change</p>

<pre><code>this.VM.$root.$broadcast('get-tentative-events', []);
</code></pre>

<p>to</p>

<pre><code>this.VM.addEvents([])
</code></pre>

<p>I can pass this test.So I can not understand why my test is failing.</p>