From 870e231494435ac5ff2e6053f294077a26319185 Mon Sep 17 00:00:00 2001 From: Marcos Castilhos <221008300@aluno.unb.br> Date: Fri, 8 Dec 2023 18:49:00 -0300 Subject: [PATCH] Update profile.component.spec.ts --- src/app/pages/profile/profile.component.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/pages/profile/profile.component.spec.ts b/src/app/pages/profile/profile.component.spec.ts index 59ffc550..111128a0 100644 --- a/src/app/pages/profile/profile.component.spec.ts +++ b/src/app/pages/profile/profile.component.spec.ts @@ -38,9 +38,7 @@ class AlertServiceMock { class AuthServiceMock { logout() { } - refreshToken() { - return of({ success: true }); - } + refreshToken() { } } class ConfirmationServiceMock { @@ -137,6 +135,15 @@ describe('ProfileComponent', () => { expect(localStorage.getItem('token')).toEqual('new_access_token'); }); + it('should handle error when renewing token', () => { + spyOn(authService, 'refreshToken').and.returnValue(throwError('error')); + spyOn(console, 'error'); + + component.renewToken(); + + expect(authService.refreshToken).toHaveBeenCalled(); + expect(console.error).toHaveBeenCalledWith('Failed to refresh token:', 'error'); + }); it('should call navigatorEdit when editUser is clicked', () => { spyOn(component, 'navigatorEdit').and.callThrough();