Skip to content

Commit

Permalink
Fixes++
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Apr 25, 2024
1 parent cb53d74 commit a16d907
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
19 changes: 8 additions & 11 deletions webapp/src/pages/Calculadora/Calculadora.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { render, screen, fireEvent } from "@testing-library/react";
import CalculadoraHumana from "./Calculadora";
import { MemoryRouter } from "react-router-dom";
import { I18nextProvider } from "react-i18next";
Expand Down Expand Up @@ -40,7 +40,7 @@ test("handles correct answer", async () => {
);

// Get the initial operation
var initialOperation = screen.getByText(
let initialOperation = screen.getByText(
/(\d+)\s*([-+*/])\s*(\d+)/
).textContent;
initialOperation = initialOperation.split("=")[0];
Expand All @@ -54,7 +54,7 @@ test("handles correct answer", async () => {
fireEvent.click(submitButton);

// Check if the score has increased
var updatedScore = parseInt(
let updatedScore = parseInt(
screen
.getByText(/puntuación: (\d+)/i)
.textContent.split(":")[1]
Expand All @@ -63,7 +63,7 @@ test("handles correct answer", async () => {
expect(updatedScore).toBe(initialScore + 1);

// Get next operation
var nextOperation = screen.getByText(/(\d+)\s*([-+*/])\s*(\d+)/).textContent;
let nextOperation = screen.getByText(/(\d+)\s*([-+*/])\s*(\d+)/).textContent;
nextOperation = nextOperation.split("=")[0];

// Enter the correct answer and submit
Expand All @@ -79,9 +79,7 @@ test("handles correct answer", async () => {
);
expect(updatedScore).toBe(initialScore + 2);

await setTimeout(() => {

}, 1000);
await setTimeout(() => {}, 1000);
});

test("handles incorrect answer", () => {
Expand Down Expand Up @@ -135,7 +133,7 @@ test("handles game over", async () => {
.textContent.split(":")[1]
.trim()
);

// Get the input field and submit button
const inputField = screen.getByTitle(/number/i);
const submitButton = screen.getByRole("button", { name: /enviar/i });
Expand All @@ -156,11 +154,10 @@ test("handles game over", async () => {
.getByText(/puntuación: (\d+)/i)
.textContent.split(":")[1]
.trim()
);
);
expect(updatedScore).toBe(initialScore);

await setTimeout(() => {
screen.getByText(/jugar de nuevo/i).click();
}, 1000);

});
13 changes: 5 additions & 8 deletions webapp/src/pages/Clasico/Clasico.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ const JuegoPreguntas = () => {
} else if (respuesta === respuestaSeleccionada) {
return { backgroundColor: "red" };
}
} else {
if (respuesta === respuestaSeleccionada) {
return isDarkTheme
? { color: "#333333", backgroundColor: "#F0F0F0" }
: { backgroundColor: "#333333", color: "#F0F0F0" };
}
} else if (respuesta === respuestaSeleccionada) {
return isDarkTheme
? { color: "#333333", backgroundColor: "#F0F0F0" }
: { backgroundColor: "#333333", color: "#F0F0F0" };
}
return {};
};
Expand All @@ -154,7 +152,7 @@ const JuegoPreguntas = () => {
correcta: preguntaActual.correcta,
respuesta: respuestaSeleccionada,
};
setQuestionsToSave( [...questionsToSave, pregunta]);
setQuestionsToSave([...questionsToSave, pregunta]);

setTiempoTotal(tiempoTotal + tiempoRestante);
setRespuestaSeleccionada(null);
Expand Down Expand Up @@ -286,7 +284,6 @@ const JuegoPreguntas = () => {
<Grid templateColumns="repeat(2, 1fr)" gap={4} mt={4}>
{preguntaActual.respuestas.map((respuesta, index) => (
<Button
key={index}
onClick={() => handleRespuestaSeleccionada(respuesta)}
disabled={tiempoRestante === 0 || juegoTerminado}
style={estiloRespuesta(respuesta)}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/Config/Config.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import Config from "./Config";
import { BrowserRouter as Router } from "react-router-dom";
Expand Down

0 comments on commit a16d907

Please sign in to comment.