import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MainLayoutComponent } from './main-layout.component'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatButtonModule } from '@angular/material/button'; import { MatMenuModule } from '@angular/material/menu'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { HeaderComponent } from '../header/header.component'; import { SidebarComponent } from '../sidebar/sidebar.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; describe('MainLayoutComponent', () => { let component: MainLayoutComponent; let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [MainLayoutComponent, HeaderComponent, SidebarComponent], imports: [ MatSidenavModule, MatToolbarModule, MatButtonModule, MatMenuModule, NoopAnimationsModule, RouterTestingModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); fixture = TestBed.createComponent(MainLayoutComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should toggle sidebar visibility', () => { expect(component.isSidebarVisible).toBeFalse(); component.toggleSidebar(); expect(component.isSidebarVisible).toBeTrue(); component.toggleSidebar(); expect(component.isSidebarVisible).toBeFalse(); }); });