Skip to content

Commit

Permalink
Intento arreglo de tests 8
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289039 committed Mar 14, 2024
1 parent e021a04 commit 6fe0e7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
22 changes: 18 additions & 4 deletions .idea/workspace.xml

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

2 changes: 1 addition & 1 deletion webapp/src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Login = ({sendLogin, sendUsername}) => {
const [openSnackbar, setOpenSnackbar] = useState(false);

const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';
sendLogin(loginSuccess);
//sendLogin(loginSuccess);
const loginUser = async () => {
try {
const response = await axios.post(`${apiEndpoint}/login`, { username, password });
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/Login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Login component', () => {

// Mock the axios.post request to simulate a successful response
mockAxios.onPost('http://localhost:8000/login').reply(200, { createdAt: '2024-01-01T12:34:56Z' });
expect(sendLogin.mock.calls[0]).toBe(true);
expect(sendLogin.mock.calls[0][0]).toBe(true);
expect(sendUsername.mock.calls[0]).toBe(usernameInput);

// Simulate user input
Expand All @@ -50,7 +50,7 @@ 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(false);
expect(sendLogin.mock.calls[0][0]).toBe(false);
expect(sendUsername.mock.calls[0]).toBe(usernameInput);
// Simulate user input
fireEvent.change(usernameInput, { target: { value: 'testUser' } });
Expand Down

0 comments on commit 6fe0e7d

Please sign in to comment.