diff --git a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-medium.component.spec.ts b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-medium.component.spec.ts index 335ce176e534..f50fbcba7061 100644 --- a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-medium.component.spec.ts +++ b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-medium.component.spec.ts @@ -73,30 +73,28 @@ describe('SidebarCardMediumComponent', () => { }); it('should navigate to the item URL on click', async () => { - const mockFn = jest.fn(); - component.emitStoreAndRefresh = mockFn; + jest.spyOn(component, 'emitStoreAndRefresh'); component.itemSelected = true; fixture.detectChanges(); const itemElement = fixture.nativeElement.querySelector('#test-sidebar-card-medium'); itemElement.click(); await fixture.whenStable(); - expect(mockFn).toHaveBeenCalledWith('testId'); - expect(router.navigateByUrl).toHaveBeenCalled(); - const navigationArray = router.navigateByUrl.mock.calls[0][0]; - expect(navigationArray).toBe('./testId'); + expect(component.emitStoreAndRefresh).toHaveBeenCalledWith('testId'); + expect(router.navigate).toHaveBeenCalled(); + const navigationArray = router.navigate.mock.calls[1][0]; + expect(navigationArray).toStrictEqual(['./testId']); }); it('should navigate to the when no item was selected before', async () => { - const mockFn = jest.fn(); - component.emitStoreAndRefresh = mockFn; + jest.spyOn(component, 'emitStoreAndRefresh'); component.itemSelected = false; fixture.detectChanges(); const itemElement = fixture.nativeElement.querySelector('#test-sidebar-card-medium'); itemElement.click(); await fixture.whenStable(); - expect(mockFn).toHaveBeenCalledWith('testId'); - expect(router.navigateByUrl).toHaveBeenCalled(); - const navigationArray = router.navigateByUrl.mock.calls[0][0]; - expect(navigationArray).toBe('./testId'); + expect(component.emitStoreAndRefresh).toHaveBeenCalledWith('testId'); + expect(router.navigate).toHaveBeenCalled(); + const navigationArray = router.navigate.mock.calls[1][0]; + expect(navigationArray).toStrictEqual(['', 'testId']); }); }); diff --git a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-small.component.spec.ts b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-small.component.spec.ts index 0a38c4d118c3..fb3f4a298a56 100644 --- a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-small.component.spec.ts +++ b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-small.component.spec.ts @@ -74,30 +74,28 @@ describe('SidebarCardSmallComponent', () => { */ it('should navigate to the item URL on click', async () => { - const mockFn = jest.fn(); - component.emitStoreAndRefresh = mockFn; + jest.spyOn(component, 'emitStoreAndRefresh'); component.itemSelected = true; fixture.detectChanges(); const itemElement = fixture.nativeElement.querySelector('#test-sidebar-card-small'); itemElement.click(); await fixture.whenStable(); - expect(mockFn).toHaveBeenCalledWith('testId'); - expect(router.navigateByUrl).toHaveBeenCalled(); - const navigationArray = router.navigateByUrl.mock.calls[0][0]; - expect(navigationArray).toBe('../communication'); + expect(component.emitStoreAndRefresh).toHaveBeenCalledWith('testId'); + expect(router.navigate).toHaveBeenCalled(); + const navigationArray = router.navigate.mock.calls[1][0]; + expect(navigationArray).toStrictEqual(['./testId']); }); it('should navigate to the when no item was selected before', async () => { - const mockFn = jest.fn(); - component.emitStoreAndRefresh = mockFn; + jest.spyOn(component, 'emitStoreAndRefresh'); component.itemSelected = false; fixture.detectChanges(); const itemElement = fixture.nativeElement.querySelector('#test-sidebar-card-small'); itemElement.click(); await fixture.whenStable(); - expect(mockFn).toHaveBeenCalledWith('testId'); - expect(router.navigateByUrl).toHaveBeenCalled(); - const navigationArray = router.navigateByUrl.mock.calls[0][0]; - expect(navigationArray).toBe('./communication'); + expect(component.emitStoreAndRefresh).toHaveBeenCalledWith('testId'); + expect(router.navigate).toHaveBeenCalled(); + const navigationArray = router.navigate.mock.calls[1][0]; + expect(navigationArray).toStrictEqual(['', 'testId']); }); });