From 1f86b95c0ba0b33907604bf55b84708c64fa9aac Mon Sep 17 00:00:00 2001 From: LeonWehrhahn Date: Fri, 10 Jan 2025 22:24:54 +0100 Subject: [PATCH] fix SidebarCardLargeComponent tests --- .../sidebar-card-large.component.spec.ts | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts index 527bd39f41d5..58c2a9919109 100644 --- a/src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts +++ b/src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts @@ -48,30 +48,28 @@ describe('SidebarCardLargeComponent', () => { }); 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-large'); 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-large'); 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']); }); });