import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { SideMenuNavComponent } from './side-menu-nav.component'; import { RouterTestingModule } from '@angular/router/testing'; import { SidePanelsService } from '../../../utils/side-panels.service'; import { ApolloModule } from 'apollo-angular'; describe('SideMenuNavComponent', () => { let component: SideMenuNavComponent; let fixture: ComponentFixture; let sidePanel: SidePanelsService; beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, ApolloModule], declarations: [SideMenuNavComponent], providers: [SidePanelsService], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(SideMenuNavComponent); component = fixture.componentInstance; sidePanel = TestBed.inject(SidePanelsService); fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should toggle subMenu', () => { sidePanel.castSideMenu.subscribe(sideMenuData => { sidePanel.toggleSideMenu = jest.fn(); const subMenuData = sideMenuData[0]['menuApp']; component.toggleSubMenu('Demand Forecasting'); expect(sidePanel.toggleSideMenu).toHaveBeenCalledWith(subMenuData); }); }); });