Skip to content

Commit

Permalink
probando
Browse files Browse the repository at this point in the history
  • Loading branch information
uo287627 committed Apr 28, 2024
1 parent 8b8809e commit 1649f96
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions webapp/src/components/Login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@ const mockAxios = new MockAdapter(axios);

// Define the test suite
describe('Login Component', () => {
// Define the test
test('renders login button', () => {
// Render the Login component
render(<Login setLogged={() => {}} />);

// Check if the login button is in the document
const loginButton = screen.getByRole('button', { name: /Iniciar sesión/i });
expect(loginButton).toBeInTheDocument();
});

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);
}
});

Expand All @@ -35,6 +27,15 @@ describe('Login Component', () => {
return Promise.resolve({ data: { users: ['user1', 'user2'] } });
}
});
// Define the test
test('renders login button', () => {
// Render the Login component
render(<Login setLogged={() => {}} />);

// Check if the login button is in the document
const loginButton = screen.getByRole('button', { name: /Iniciar sesión/i });
expect(loginButton).toBeInTheDocument();
});

test('login with valid normal (not "admin") credentials', async () => {
const setLogged = jest.fn();
Expand Down

0 comments on commit 1649f96

Please sign in to comment.