I want make a testing in my project and the function I want test is a nested function, there function in function
the function like this:
ngOnInit() {
this.getMenu()
}
this is my test spec:
describe('NavigationComponent', () => {
let component: NavigationComponent;
let fixture: ComponentFixture<NavigationComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
],
providers: [
{ provide: AuthenticationService, useClass: MockAuthenticationService }
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NavigationComponent);
//navComponent = TestBed.createComponent(NavigationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('getMenu should called', ()=>{
spyOn(component, 'getMenu');
fixture.detectChanges();
expect(component.getMenu).toHaveBeenCalled();
})
It's work when I test ngOnInit, but I don't know how to test "getMenu"
thanks for the help