From afb150dd4c82ae62ae9ba189ad046244cfcddf24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Molt=C3=B3?= Date: Fri, 29 Mar 2024 22:30:29 +0100 Subject: [PATCH] Test --- webapp/src/test/Nav.test.js | 6 ++++++ webapp/src/test/Question.test.js | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/webapp/src/test/Nav.test.js b/webapp/src/test/Nav.test.js index 246fd9e8..14a52419 100644 --- a/webapp/src/test/Nav.test.js +++ b/webapp/src/test/Nav.test.js @@ -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( diff --git a/webapp/src/test/Question.test.js b/webapp/src/test/Question.test.js index 344c3e19..56c9a256 100644 --- a/webapp/src/test/Question.test.js +++ b/webapp/src/test/Question.test.js @@ -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( + + ); + + // Simulamos que se ha alcanzado el lĂ­mite de preguntas + act(() => { + rerender( + + ); + }); + + //expect(mockedFinishByQuestions).toHaveBeenCalled(); + expect(mockedFinishByTime).not.toHaveBeenCalled(); + }); });