Skip to content

Commit

Permalink
Update profile.component.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcosatc147 committed Dec 8, 2023
1 parent 932210e commit 870e231
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/pages/profile/profile.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ class AlertServiceMock {

class AuthServiceMock {
logout() { }
refreshToken() {
return of({ success: true });
}
refreshToken() { }
}

class ConfirmationServiceMock {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 870e231

Please sign in to comment.