Skip to content

Commit

Permalink
Refactor some lines into single function
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287741 committed Apr 29, 2024
1 parent c4eb539 commit e6df3f1
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions webapp/src/components/group/NoGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ describe('NoGroup component', () => {
await waitFor(() => {
expect(screen.getByTestId('join-group-modal')).toBeInTheDocument();
});
// Simula la llamada a joinGroup
await act(async () => {
await fireEvent.click(screen.getByTestId(`join-group-button`));
});
// Simula una respuesta exitosa de la API
axios.post.mockResolvedValueOnce({});
});

test('clicking on "Create a group" button opens the create modal', async () => {
Expand All @@ -66,25 +72,4 @@ describe('NoGroup component', () => {
});
});

test('joining a group calls the joinGroup API', async () => {
render(<NoGroup />);

// Simula hacer clic en el botón "Join a group" para abrir el modal
fireEvent.click(screen.getByTestId('join-group-button'));

// Verifica que el modal de join group se muestre en el DOM
await waitFor(() => {
expect(screen.getByTestId('join-group-modal')).toBeInTheDocument();
});

// Simula la llamada a joinGroup
await act(async () => {
await fireEvent.click(screen.getByTestId(`join-group-button`));
});
// Simula una respuesta exitosa de la API
axios.post.mockResolvedValueOnce({});


});

});

0 comments on commit e6df3f1

Please sign in to comment.