From d469ebc5b9bdbda66326e5d527eb4ab792fcb480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20D=C3=ADaz=20Cancillo?= Date: Sun, 28 Apr 2024 13:45:17 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A1s=20intentos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/components/Login.js | 2 -- webapp/src/components/Login.test.js | 20 ++------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index 807f7841..7b822ac0 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -43,13 +43,11 @@ const Login = ({ setLogged }) => { const loginUser = async () => { try { - console.error("En login estamos"); const response = await axios.post(`${apiEndpoint}/login`, { username, password }); console.error("RESPONSE... "+response); const { createdAt: userCreatedAt } = response.data; await axios.get(`${apiEndpoint}/getAllUsers`); // const users = usersResponse.data; - console.error("USERCREATEDAT "+userCreatedAt); setCreatedAt(userCreatedAt); setLoginSuccess(true); setLogged(); diff --git a/webapp/src/components/Login.test.js b/webapp/src/components/Login.test.js index 10625052..76f5ccb5 100644 --- a/webapp/src/components/Login.test.js +++ b/webapp/src/components/Login.test.js @@ -11,22 +11,6 @@ const mockAxios = new MockAdapter(axios); // Define the test suite describe('Login Component', () => { - axios.post.mockImplementation((url, data) => { - if (url.endsWith('/login')) { - console.error("En login estamos manejandonos con el mock de axios"); //borrar - return Promise.resolve({ data: { createdAt: 'mockedToken' } }); - }else if (url.endsWith('/createUserRank')) { - return Promise.resolve({ data: { rankId: 'mockedRankId' } }); - }else{ - console.error("NO ENTRAMOS "+url + " - " + data); - } - }); - - axios.get.mockImplementation((url) => { - if (url.endsWith('/getAllUsers')) { - return Promise.resolve({ data: { users: ['user1', 'user2'] } }); - } - }); // Define the test test('renders login button', () => { // Render the Login component @@ -52,12 +36,12 @@ describe('Login Component', () => { expect(usernameInput).toBeInTheDocument(); expect(passwordInput).toBeInTheDocument(); - /* // Mock the axios.post & axios.get requests to simulate successful responses mockAxios.onPost('http://localhost:8000/login').reply(200, { data: { createdAt: '2024-01-01T12:34:56Z' }}); + mockAxios.onPost('http://localhost:8002/login').reply(200, { data: { createdAt: '2024-01-01T12:34:56Z' }}); + mockAxios.onGet('http://localhost:8000/getAllUsers').reply(200, { data: []}); mockAxios.onPost('http://localhost:8000/createUserRank').reply(200); - */ await act(async () => { // Simulate user input