Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287747 committed Apr 4, 2024
1 parent ece187f commit 17a16d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions webapp/src/components/Question.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Question.js
import React, { useState, useEffect, useContext } from 'react';
import { act } from 'react-dom/test-utils';
import { Card, List, ListItem, ListItemButton, ListItemText, Typography } from '@mui/material';
import { SessionContext } from '../SessionContext';
import correctSound from '../audio/correct.mp3';
Expand Down Expand Up @@ -139,17 +140,20 @@ const Question = ({ goTo, setGameFinished, gameMode, category, restart }) => {
});
const data = await response.json();

setQuestion(data.question);
setCorrect(data.correct);
setOptions(shuffleOptions([data.correct, ...data.incorrects]));
act(() => {
setQuestion(data.question);
setCorrect(data.correct);
setOptions(shuffleOptions([data.correct, ...data.incorrects]));

setSelectedOption(null);
setIsSelected(false);
setNQuestion((prevNQuestion) => prevNQuestion + 1);
setSelectedOption(null);
setIsSelected(false);
setNQuestion((prevNQuestion) => prevNQuestion + 1);

if (gameMode === "classic" || gameMode === "category") {
handleClassicGameFinish(nQuestion, numberCorrect, numberIncorrect, segundos,
sonido, goTo, setGameFinished);
}
});
} catch (error) {
console.error('Error fetching question:', error);
}
Expand Down

0 comments on commit 17a16d0

Please sign in to comment.