title: Angular Unit Testing for HostListener (Window Resize)
body: <p>I have a component file that has below code</p>
  <pre><code>@HostListener('window:resize', ['$event'])
  onResize(event) {
      this.width = event.target.innerWidth;
  }
  </code></pre>
  <p>I want to test it. I have tried with the below code in my spec file.</p>
  <pre><code>window.dispatchEvent(new Event(&quot;resize&quot;);
  expect(component.onResize).toHaveBeenCalled();
  </code></pre>
  <p>but it is not working. Any help will be appreciated.</p>