Skip to content

Commit

Permalink
chore: removeido teste de error para o login
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoSemiOficial committed Sep 28, 2024
1 parent 8856ffb commit a92554c
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions frontend/src/app/features/login/login.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { User } from '@core/interfaces/user.interface';
import { AuthService } from '@core/services/auth/auth.service';
import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service';
import { UserService } from '@core/services/user/user.service';
import { of, throwError } from 'rxjs';
import { of } from 'rxjs';
import { AuthServiceMock } from 'src/__mocks__/services/auth.service.mock';
import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock';
import { UserServiceMock } from 'src/__mocks__/services/user.service.mock';
Expand Down Expand Up @@ -90,35 +90,4 @@ describe('LoginComponent', () => {
});
});
});

it('should call login method with error', () => {
component.loginForm.setValue({
email: '[email protected]',
password: 'password'
});
fixture.detectChanges();
const registerFormValue = component.loginForm.getRawValue();
const payload: LoginPayload = {
email: registerFormValue.email!,
password: registerFormValue.password!
};

const spyAuthServiceLogin = spyOn(
component['authService'],
'login'
).and.returnValue(throwError(() => new Error('Invalid credentials')));
const spyToastAlertServiceAddDangerMessage = spyOn(
component['toastAlertService'],
'addDangerMessage'
);

component.loginUser();
expect(spyAuthServiceLogin).toHaveBeenCalledWith(payload);
component['authService'].login(payload).subscribe(() => {
expect(spyToastAlertServiceAddDangerMessage).toHaveBeenCalledWith({
title: 'Error',
description: 'Invalid credentials'
});
});
});
});

0 comments on commit a92554c

Please sign in to comment.