Skip to content

Commit 0a46e9b

Browse files
committed
Fix: Update navigation service calls in NavButtonComponent tests to use navigateToRoute
1 parent 5a8b8d2 commit 0a46e9b

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/app/shared/components/buttons/nav-button/nav-button.component.spec.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('NavButtonComponent', () => {
1515
navigationServiceSpy = jasmine.createSpyObj('NavigationService', [
1616
'navigateToHome',
1717
'navigateToSection',
18+
'navigateToRoute',
1819
]);
1920
themeServiceSpy = jasmine.createSpyObj('ThemeService', [], {
2021
activeTheme: activeThemeSignal,
@@ -260,15 +261,15 @@ describe('NavButtonComponent', () => {
260261
});
261262

262263
describe('navigate()', () => {
263-
it('should call navigateToHome when no fragment is provided', () => {
264+
it('should call navigateToRoute when no fragment is provided', () => {
264265
fixture.componentRef.setInput('label', 'Home');
265266
fixture.componentRef.setInput('icon', 'home');
266267
fixture.componentRef.setInput('routerLink', '/');
267268
fixture.detectChanges();
268269

269270
component.navigate();
270271

271-
expect(navigationServiceSpy.navigateToHome).toHaveBeenCalled();
272+
expect(navigationServiceSpy.navigateToRoute).toHaveBeenCalledWith('/');
272273
expect(navigationServiceSpy.navigateToSection).not.toHaveBeenCalled();
273274
});
274275

@@ -282,7 +283,7 @@ describe('NavButtonComponent', () => {
282283
component.navigate();
283284

284285
expect(navigationServiceSpy.navigateToSection).toHaveBeenCalledWith('about', '/');
285-
expect(navigationServiceSpy.navigateToHome).not.toHaveBeenCalled();
286+
expect(navigationServiceSpy.navigateToRoute).not.toHaveBeenCalled();
286287
});
287288

288289
it('should call navigateToSection when fragment is provided with array routerLink', () => {
@@ -295,7 +296,7 @@ describe('NavButtonComponent', () => {
295296
component.navigate();
296297

297298
expect(navigationServiceSpy.navigateToSection).toHaveBeenCalledWith('projects', '/');
298-
expect(navigationServiceSpy.navigateToHome).not.toHaveBeenCalled();
299+
expect(navigationServiceSpy.navigateToRoute).not.toHaveBeenCalled();
299300
});
300301

301302
it('should use first element of array routerLink for section navigation', () => {
@@ -456,7 +457,7 @@ describe('NavButtonComponent', () => {
456457
expect(component.navigate).toHaveBeenCalled();
457458
});
458459

459-
it('should call navigateToHome when clicked without fragment', () => {
460+
it('should call navigateToRoute when clicked without fragment', () => {
460461
fixture.componentRef.setInput('label', 'Home');
461462
fixture.componentRef.setInput('icon', 'home');
462463
fixture.componentRef.setInput('routerLink', '/');
@@ -465,7 +466,7 @@ describe('NavButtonComponent', () => {
465466
const button = fixture.nativeElement.querySelector('button.nav-btn');
466467
button.click();
467468

468-
expect(navigationServiceSpy.navigateToHome).toHaveBeenCalled();
469+
expect(navigationServiceSpy.navigateToRoute).toHaveBeenCalledWith('/');
469470
});
470471

471472
it('should call navigateToSection when clicked with fragment', () => {
@@ -493,7 +494,7 @@ describe('NavButtonComponent', () => {
493494
component.navigate();
494495
component.navigate();
495496

496-
expect(navigationServiceSpy.navigateToHome).toHaveBeenCalledTimes(3);
497+
expect(navigationServiceSpy.navigateToRoute).toHaveBeenCalledTimes(3);
497498
});
498499

499500
it('should update icon path when icon changes', () => {
@@ -518,7 +519,7 @@ describe('NavButtonComponent', () => {
518519

519520
component.navigate();
520521

521-
expect(navigationServiceSpy.navigateToHome).toHaveBeenCalled();
522+
expect(navigationServiceSpy.navigateToRoute).toHaveBeenCalledWith('');
522523
});
523524

524525
it('should handle empty array routerLink with fragment', () => {

0 commit comments

Comments
 (0)