Skip to content

Commit

Permalink
Intento arreglo de tests 5
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289039 committed Mar 14, 2024
1 parent c07f666 commit 9a745a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 13 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion webapp/src/components/Login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe('Login component', () => {
});

it('should handle error when logging in', async () => {
render(<Login />);
const sendLogin=jest.fn();
const sendUsername=jest.fn();
render(<Login sendLogin={sendLogin()} sendUsername={sendUsername()}/>);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
Expand All @@ -48,6 +50,8 @@ describe('Login component', () => {
// Mock the axios.post request to simulate an error response
mockAxios.onPost('http://localhost:8000/login').reply(401, { error: 'Unauthorized' });

expect(sendLogin.mock.calls[0]).toBe(true);
expect(sendUsername.mock.calls[0]).toBe(usernameInput);
// Simulate user input
fireEvent.change(usernameInput, { target: { value: 'testUser' } });
fireEvent.change(passwordInput, { target: { value: 'testPassword' } });
Expand Down

0 comments on commit 9a745a0

Please sign in to comment.