forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
10 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 |
---|---|---|
@@ -1,16 +1,42 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { Game } from '../components/Game'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import { Game } from '../components/Game'; // Importamos el componente correcto | ||
|
||
describe('Game component', () => { | ||
test('renders question correctly', async () => { | ||
render(<Game goTo={(parameter) => {}} />); | ||
describe('Question Component', () => { | ||
|
||
// Espera a que se cargue la pregunta | ||
await waitFor(() => screen.getByText(/Question/i)); | ||
test('fetches and displays a question with options', async () => { | ||
const { getByText, getAllByRole } = render(<Game goTo={() => {}} />); // Renderizamos el componente correcto y simulamos la función goTo | ||
|
||
// Verifica que la pregunta se renderice correctamente | ||
expect(screen.getByText(/Question/i)).toBeInTheDocument(); | ||
|
||
// Esperamos a que se muestre la pregunta | ||
await waitFor(() => { | ||
expect(getByText('Question: 1')).toBeInTheDocument(); | ||
}); | ||
|
||
// Esperamos a que se muestren las opciones | ||
await waitFor(() => { | ||
expect(getAllByRole('listitem')).toHaveLength(4); // Asumimos que hay 4 opciones (la pregunta más 3 opciones incorrectas) | ||
}); | ||
}); | ||
|
||
test('selects an option and displays feedback', async () => { | ||
const { getByText, getAllByRole } = render(<Game goTo={() => {}} />); // Renderizamos el componente correcto y simulamos la función goTo | ||
|
||
// Esperamos a que se muestre la pregunta | ||
await waitFor(() => { | ||
expect(getByText('Question: 1')).toBeInTheDocument(); | ||
}); | ||
|
||
// Seleccionamos una opción (simulamos hacer clic) | ||
const options = getAllByRole('listitem'); | ||
fireEvent.click(options[0]); // Suponemos que la primera opción es la correcta | ||
|
||
// Esperamos a que se muestre el botón Next | ||
await waitFor(() => { | ||
expect(getByText('Next')).toBeInTheDocument(); | ||
}); | ||
|
||
}); | ||
|
||
// Agrega más tests según sea necesario para cubrir otros comportamientos del componente | ||
}); | ||
|