Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287747 committed Mar 29, 2024
1 parent a8f0390 commit afb150d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webapp/src/test/Nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ describe('Nav Component', () => {
expect(getByText('noUser')).toBeInTheDocument();
});







test('calls goToMenuClic when the button "Menu" is clicked', async () => {
const goToMock = jest.fn();
const { getByText } = render(
Expand Down
24 changes: 24 additions & 0 deletions webapp/src/test/Question.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,28 @@ describe('handleGameFinish function', () => {
expect(localStorage.getItem('pFalladas')).toBeDefined();
});

it('should finish the game when the number of questions reaches the limit', () => {
const mockedFinishByQuestions = jest.fn();
const mockedFinishByTime = jest.fn();

const { rerender } = render(
<SessionProvider><Question
goTo={jest.fn()}
setGameFinished={true}
/></SessionProvider>
);

// Simulamos que se ha alcanzado el límite de preguntas
act(() => {
rerender(
<SessionProvider><Question
goTo={jest.fn()}
setGameFinished={true}
/></SessionProvider>
);
});

//expect(mockedFinishByQuestions).toHaveBeenCalled();
expect(mockedFinishByTime).not.toHaveBeenCalled();
});
});

0 comments on commit afb150d

Please sign in to comment.