Skip to content

Commit

Permalink
game test v3
Browse files Browse the repository at this point in the history
  • Loading branch information
UO290054 committed Apr 29, 2024
1 parent d7d63dd commit 62cdf58
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions webapp/src/components/Game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,31 @@ describe('Game component', () => {
});
});


it('should handle timeout correctly', async () => {
// Define una función simulada para handleShowQuestion
const handleShowQuestion = jest.fn();

renderGameComponent({ handleShowQuestion }); // Pasa la función simulada como propiedad

await waitFor(() => {
mockAxios.onGet('http://localhost:8000/createquestion').reply(200, { data: mockQuestionData });
});

await waitFor(() => {
if (screen.queryByText(/Pregunta 1:/i)) {
jest.advanceTimersByTime(10000);
expect(screen.getByText(correctOption)).toHaveStyle({ backgroundColor: 'rgba(79, 141, 18, 0.726)' });
expect(incrementIncorrect).toHaveBeenCalledTimes(1);
expect(decrementQuestionsToAnswer).toHaveBeenCalledTimes(1);
}
});

await waitFor(() => {
expect(handleShowQuestion).toHaveBeenCalledTimes(0); // Verifica que handleShowQuestion se llame una vez
});
});



});

0 comments on commit 62cdf58

Please sign in to comment.