diff --git a/webapp/src/components/CustomModal/CustomModal.js b/webapp/src/components/CustomModal/CustomModal.js
index 987c473e..15b71334 100644
--- a/webapp/src/components/CustomModal/CustomModal.js
+++ b/webapp/src/components/CustomModal/CustomModal.js
@@ -21,10 +21,10 @@ const CustomModal = ({ title, text, route }) => {
-
diff --git a/webapp/src/components/Preguntas.js b/webapp/src/components/Preguntas.js
deleted file mode 100644
index 99a0cfdd..00000000
--- a/webapp/src/components/Preguntas.js
+++ /dev/null
@@ -1,20 +0,0 @@
-const axios = require('axios');
-
-// Definir la función para realizar la solicitud
-async function fetchQuestions() {
- const url = 'http://localhost:8003/questions';
- const params = {
- tematica: 'all',
- n: 100
- };
-
- try {
- const response = await axios.get(url, { params });
- return response.data;
- } catch (error) {
- throw new Error('Error al obtener las preguntas:', error);
- }
-}
-
-// Exportar la función
-module.exports = { fetchQuestions };
diff --git a/webapp/src/components/Stats.js b/webapp/src/components/Stats.js
deleted file mode 100644
index 1c47483f..00000000
--- a/webapp/src/components/Stats.js
+++ /dev/null
@@ -1,21 +0,0 @@
-const axios = require('axios');
-
-// Definir la función para realizar la solicitud
-async function fetchStats() {
- const username = localStorage.getItem('username');
- const url = 'http://localhost:8004/stats';
- const params = {
- user: username,
- gamemode: "clasico"
- };
-
- try {
- const response = await axios.get(url, { params });
- return response.data;
- } catch (error) {
- throw new Error('Error al obtener las estadísticas:', error);
- }
-}
-
-// Exportar la función
-module.exports = { fetchStats };
\ No newline at end of file
diff --git a/webapp/src/pages/Clasico/Clasico.test.js b/webapp/src/pages/Clasico/Clasico.test.js
index 88796e23..8b8c2137 100644
--- a/webapp/src/pages/Clasico/Clasico.test.js
+++ b/webapp/src/pages/Clasico/Clasico.test.js
@@ -2,13 +2,13 @@ import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import Clasico from "./Clasico";
-import { BrowserRouter as Router } from "react-router-dom";
+import { MemoryRouter } from "react-router-dom";
beforeEach(() => {
jest.resetAllMocks();
});
-describe("JuegoPreguntas Component", () => {
+describe("Clasico Component", () => {
test("renders game questions and handles user answers", async () => {
const mockQuestions = [
{
@@ -29,9 +29,9 @@ describe("JuegoPreguntas Component", () => {
});
render(
-
+
-
+
);
// Verificar que las preguntas se rendericen correctamente
@@ -51,7 +51,64 @@ describe("JuegoPreguntas Component", () => {
// Verificar que la respuesta seleccionada se resalte correctamente
expect(screen.getByText("París")).toHaveStyle('backgroundColor: "#10FF00"');
+ // Simular el siguiente paso del juego
+ const button = screen.getByText("Responder");
+ button.click();
+
+ await waitFor(
+ () => {
+ expect(
+ screen.getByText("¿Cuál es el río más largo del mundo?")
+ ).toBeInTheDocument();
+ expect(screen.getByText("Amazonas")).toBeInTheDocument();
+ expect(screen.getByText("Nilo")).toBeInTheDocument();
+ expect(screen.getByText("Misisipi")).toBeInTheDocument();
+ expect(screen.getByText("Yangtsé")).toBeInTheDocument();
+ },
+ { timeout: 30000 }
+ );
+
+ // Simular la selección de una respuesta incorrecta
+ fireEvent.click(screen.getByText("Nilo"));
+
+ // Verificar que la respuesta seleccionada se resalte correctamente
+ expect(screen.getByText("Amazonas")).toHaveStyle('backgroundColor: "#10FF00"');
+
// Simular el siguiente paso del juego
fireEvent.click(screen.getByText("Responder"));
+
+ await waitFor(
+ () => {
+ expect(screen.getByText("¡Juego terminado!")).toBeInTheDocument();
+ expect(screen.getByText("Repetir Juego")).toBeInTheDocument();
+ expect(screen.getByText("Volver al Menú Principal")).toBeInTheDocument();
+ },
+ { timeout: 30000 }
+ );
+
+ fireEvent.click(screen.getByText("Repetir Juego"));
+ }, 50000);
+
+ test("renders game questions and handles errors", async () => {
+ jest.spyOn(global, "fetch").mockImplementationOnce(() =>
+ Promise.resolve({
+ ok: false,
+ status: 400,
+ json: () => Promise.resolve({ error: "Failed to fetch" }),
+ })
+ );
+
+ render(
+
+
+
+ );
+
+ await waitFor(
+ () => {
+ expect(screen.getByText("Loading...")).toBeInTheDocument();
+ },
+ { timeout: 30000 }
+ );
});
});