generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Tests-Final' of https://github.com/Arquisoft/wiq_en2a i…
…nto Tests-Final
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import axios from 'axios'; // Mockear axios | ||
import { CreationModal } from './GroupCreationModal'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('CreationModal component', () => { | ||
test('renders the modal properly', async () => { | ||
const { getByText, getByLabelText } = render(<CreationModal nowHasGroup={() => {}} setError={() => {}} toggleCreateModal={() => {}} />); | ||
|
||
// Verifica que el título del modal esté presente | ||
expect(getByText('Create group')).toBeInTheDocument(); | ||
|
||
// Verifica que los elementos de entrada estén presentes | ||
expect(getByLabelText('Group name')).toBeInTheDocument(); | ||
expect(getByText('Yes')).toBeInTheDocument(); | ||
expect(getByText('No')).toBeInTheDocument(); | ||
expect(getByLabelText('Description')).toBeInTheDocument(); | ||
}); | ||
|
||
test('clicking on the create button calls the createGroup function', async () => { | ||
const mockNowHasGroup = jest.fn(); | ||
const mockSetError = jest.fn(); | ||
const mockToggleCreateModal = jest.fn(); | ||
|
||
const { getByText } = render(<CreationModal nowHasGroup={mockNowHasGroup} setError={mockSetError} toggleCreateModal={mockToggleCreateModal} />); | ||
|
||
// Simula hacer clic en el botón de creación | ||
fireEvent.click(getByText('Create group')); | ||
|
||
|
||
}); | ||
|
||
test('changing the group name updates the state', async () => { | ||
const { getByLabelText } = render(<CreationModal nowHasGroup={() => {}} setError={() => {}} toggleCreateModal={() => {}} />); | ||
|
||
// Simula cambiar el valor del nombre del grupo | ||
fireEvent.change(getByLabelText('Group name'), { target: { value: 'New Group' } }); | ||
|
||
// Verifica que el valor del nombre del grupo haya sido actualizado | ||
expect(getByLabelText('Group name')).toHaveValue('New Group'); | ||
}); | ||
|
||
// Agrega más tests según sea necesario para cubrir otras funcionalidades y casos de uso. | ||
}); |