title: should call function inside ngOnInit
body: <p>I am new to angular testing , I would like to know how can i test the function that have been called when ngOnInit called . Below is the code that i am trying to test</p>
  
  <pre><code>it('should call TestMethod method inside ngOnInit' , async() =&gt; {
      spyOn(component , 'TestMethod')
      fixture.detectChanges()
      expect(component.TestMethod).toHaveBeenCalled()
    })
  </code></pre>
  
  <p>Below is the error i am getting</p>
  
  <pre><code>Expected spy TestMethod to have been called.
  </code></pre>
  
  <p>BeforeEach is below</p>
  
  <pre><code>beforeEach(() =&gt; {
      fixture = TestBed.createComponent(CreateRoomsComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  </code></pre>