From 88abd309a5032771f095f4a058d18b5e3d8636db Mon Sep 17 00:00:00 2001 From: Anton Ramanovich Date: Wed, 18 Jun 2025 12:18:50 +0200 Subject: [PATCH] ACS-8770: fixes test with rejected promise improper usage --- .../src/lib/directives/library-favorite.directive.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/directives/library-favorite.directive.spec.ts b/lib/content-services/src/lib/directives/library-favorite.directive.spec.ts index f27503bff9..43f03ad8f4 100644 --- a/lib/content-services/src/lib/directives/library-favorite.directive.spec.ts +++ b/lib/content-services/src/lib/directives/library-favorite.directive.spec.ts @@ -84,7 +84,7 @@ describe('LibraryFavoriteDirective', () => { }); it('should call addFavorite() and display snackbar message on click event when selection is not a favorite', async () => { - spyOn(component.directive.favoritesApi, 'getFavoriteSite').and.returnValue(Promise.reject(new Error('error'))); + spyOn(component.directive.favoritesApi, 'getFavoriteSite').and.callFake(() => Promise.reject(new Error('error'))); spyOn(component.directive.favoritesApi, 'createFavorite').and.returnValue(Promise.resolve(null)); spyOn(notificationService, 'showInfo'); @@ -99,6 +99,7 @@ describe('LibraryFavoriteDirective', () => { await fixture.whenStable(); expect(component.directive.favoritesApi.createFavorite).toHaveBeenCalled(); + expect(component.directive.favoritesApi.getFavoriteSite).not.toHaveBeenCalled(); expect(notificationService.showInfo).toHaveBeenCalledWith('NODE_FAVORITE_DIRECTIVE.MESSAGES.NODE_ADDED', null, { name: 'Site' }); });