Skip to content

Commit

Permalink
✅ increase navigation components coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bunop committed Jun 21, 2024
1 parent e1da260 commit eb2e43e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/navigation/header/header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { By } from '@angular/platform-browser';

import { MaterialModule } from '../../material/material.module';
import { HeaderComponent } from './header.component';
Expand Down Expand Up @@ -32,4 +33,19 @@ describe('HeaderComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should call onToggleSidenav when the menu button is clicked', () => {
spyOn(component, 'onToggleSidenav');
const button = fixture.debugElement.query(By.css('button[mat-icon-button]')).nativeElement;
button.click();
expect(component.onToggleSidenav).toHaveBeenCalled();
});

it('should emit sidenavToggle event when onToggleSidenav is called', () => {
spyOn(component.sidenavToggle, 'emit');

component.onToggleSidenav();

expect(component.sidenavToggle.emit).toHaveBeenCalled();
});
});
17 changes: 17 additions & 0 deletions src/app/navigation/sidenav-list/sidenav-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@ describe('SidenavListComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should emit closeSidenav event when onClose is called', () => {
spyOn(component.closeSidenav, 'emit');

component.onClose();

expect(component.closeSidenav.emit).toHaveBeenCalled();
});

it('should call onClose when onLogout is called', () => {
spyOn(component, 'onClose');

component.onLogout();

expect(component.onClose).toHaveBeenCalled();
});

});

0 comments on commit eb2e43e

Please sign in to comment.