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
15 additions
and
15 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,42 +1,42 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import { Game } from '../components/Game'; // Importamos el componente correcto | ||
import { Game } from '../components/Game'; | ||
|
||
describe('Question Component', () => { | ||
|
||
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 | ||
|
||
// Esperamos a que se muestre la pregunta | ||
test('renders question and options', async () => { | ||
const { getByText, getAllByRole } = render(<Game goTo={() => {}} />); | ||
|
||
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) | ||
expect(getAllByRole('listitem')).toHaveLength(4); | ||
}); | ||
}); | ||
|
||
test('selects an option and displays feedback', async () => { | ||
const { getByText, getAllByRole } = render(<Game goTo={() => {}} />); // Renderizamos el componente correcto y simulamos la función goTo | ||
const { getByText, getAllByRole } = render(<Game 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 | ||
fireEvent.click(options[0]); // Select the first option | ||
|
||
// 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 | ||
}); | ||
test('handles clicking "Next" button', async () => { | ||
const { getByText, queryByText } = render(<Game goTo={() => {}} />); | ||
|
||
await waitFor(() => { | ||
expect(getByText('Question: 1')).toBeInTheDocument(); | ||
}); | ||
|
||
}); | ||
}); |