From 0e57d536f3bfafff211d3e27ec7e717898530a56 Mon Sep 17 00:00:00 2001 From: Felipe Garcia Date: Sun, 10 Mar 2024 22:04:52 +0100 Subject: [PATCH] =?UTF-8?q?Correcci=C3=B3n=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/package-lock.json | 21 +++++++++++++++++++++ webapp/src/components/QuizGame.test.js | 26 +++++++++++++------------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/webapp/package-lock.json b/webapp/package-lock.json index dd759ba0..612b1a17 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -21,6 +21,7 @@ "react-responsive": "^9.0.2", "react-router-dom": "^6.22.1", "react-scripts": "5.0.1", + "react-toastify": "^8.0.2", "web-vitals": "^3.5.1" }, "devDependencies": { @@ -23202,6 +23203,26 @@ "node": ">=10" } }, + "node_modules/react-toastify": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-8.2.0.tgz", + "integrity": "sha512-Pg2Ju7NngAamarFvLwqrFomJ57u/Ay6i6zfLurt/qPynWkAkOthu6vxfqYpJCyNhHRhR4hu7+bySSeWWJu6PAg==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, + "node_modules/react-toastify/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/webapp/src/components/QuizGame.test.js b/webapp/src/components/QuizGame.test.js index 11998be6..20a6a4f0 100644 --- a/webapp/src/components/QuizGame.test.js +++ b/webapp/src/components/QuizGame.test.js @@ -9,19 +9,19 @@ beforeEach(() => { mockAxios.reset(); }); -test('Pregunta correcta', () => { + test('Pregunta correcta', async () => { mockAxios.onGet('http://localhost:8000/generate-question').reply(200, { - question: "pregunta", - correctAnswer: "correcta", - allAnswers: ["correcta","no1","no2","no3"]}); - - render(); - expect(screen.getByText(/Loading questions.../i)).toBeInTheDocument(); - + question: "pregunta", + correctAnswer: "correcta", + allAnswers: ["correcta", "no1", "no2", "no3"] + }); - - const correcta = screen.getByRole('button', { name: /correcta/i }); - fireEvent.click(correcta); - + render(); + expect(screen.getByText(/Loading questions.../i)).toBeInTheDocument(); + + // Wait for the asynchronous operation to complete + await screen.findByRole('button', { name: /correcta/i }); -}); \ No newline at end of file + const correcta = screen.getByRole('button', { name: /correcta/i }); + fireEvent.click(correcta); + }); \ No newline at end of file