Skip to content

Commit

Permalink
test for game config
Browse files Browse the repository at this point in the history
  • Loading branch information
uo288574 committed Apr 26, 2024
1 parent 9a4916d commit f8e9e29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 2 additions & 6 deletions webapp/src/components/game/GameConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ const previousBackgroundColor = '#1a1a1a'

const GameConfiguration = () => {

let tematicas
let state = useLocation().state
let tematicas = [];
let state = useLocation().state;
if( state !== null)
tematicas = state.topics;
else
tematicas = []
console.log(tematicas)


// Almacen de temáticas
const [tematicasSeleccionadas, setTematicasSeleccionadas] = useState([]);
// Almacen para el número de preguntas
Expand All @@ -34,7 +31,6 @@ const GameConfiguration = () => {

const [numRes, setNumRes] = useState(2);


const handleTematicaChange = (event) => {
const tematicaSeleccionada = event.target.value;

Expand Down
18 changes: 17 additions & 1 deletion webapp/src/components/game/GameConfiguration.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen } from '@testing-library/react';
import { render, screen, fireEvent } from '@testing-library/react';
import { ContextFun } from '../Context';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
Expand Down Expand Up @@ -49,5 +49,21 @@ describe("Game Configuration", () => {
expect(numPreguntas).toHaveLength(1);
});

test("modify number of questions for game",async () => {

const { getByLabelText } =
render(
<ContextFun>
<Router>
<GameConfiguration />
</Router>
</ContextFun>
);

const input = getByLabelText('Número de respuestas:');
fireEvent.change(input, { target: { value: '5' } });
expect(input.value).toBe('5');
});

});

0 comments on commit f8e9e29

Please sign in to comment.