diff --git a/webapp/src/components/game/Game.js b/webapp/src/components/game/Game.js deleted file mode 100644 index 5516fe74..00000000 --- a/webapp/src/components/game/Game.js +++ /dev/null @@ -1,120 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { Container, Typography, Box, LinearProgress} from '@mui/material'; -import './FirstGame.css'; -import 'react-circular-progressbar/dist/styles.css'; -import axios from 'axios'; -import { useLocation, useNavigate } from 'react-router-dom'; -import Button from '../Button'; -import GoBackButton from '../GoBackButton'; -import { Footer } from '../footer/Footer'; -import { Nav } from '../nav/Nav'; -import {shuffleArray} from '../Util' - -var questions = []; -var points = 0; -var load = true; - -const Game = () => { - - const [remTime, setRemTime] = useState(0); - - - useEffect(() => { - const time = setInterval(() => { - setRemTime((progress) => { - if(progress === 100){ - newQuestion(); - return 0; - } - const diff = 4; - return load? Math.min(progress + diff, 100) : progress; - }); - }, 400); - - return () => { - clearInterval(time); - }; - }); - - - const esperar = (ms) => { - return new Promise(resolve => setTimeout(resolve, ms)); - }; - - const getQuestions = async () => { - - }; - - const gameStore = async () => { - try { - var username = localStorage.getItem("username") - console.log(username) - console.log(questions) - const response = await axios.post(`${apiEndpoint}/storeGame`, { id, username, points, questions}); - questions = [] - points = 0 - console.log(response) - } catch (error) { - console.error(error) - } - }; - - const newQuestion = async () => { - - }; - - const checkAnswer = async (option) => { - - }; - - - return ( - <> - - - - - - - - - {allQuestions[currentQuestionIndex].question} - - - - - - {allQuestions[currentQuestionIndex].options.map((option, index) => ( - - checkAnswer(option)} - text={option} - /> - - ) - )} - - - - - - {/**/} - - - - - - - - - > - ); - -}; - -export default Game; \ No newline at end of file diff --git a/webapp/src/help/Help.test.js b/webapp/src/help/Help.test.js new file mode 100644 index 00000000..ec4b5335 --- /dev/null +++ b/webapp/src/help/Help.test.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { render, fireEvent, screen, waitFor, act } from '@testing-library/react'; +import axios from 'axios'; +import MockAdapter from 'axios-mock-adapter'; +import Help from './Help'; +import { ContextFun } from '../components/Context'; +import { BrowserRouter as Router } from 'react-router-dom'; + +const mockAxios = new MockAdapter(axios); + +describe("Help for game", () => { + + beforeEach(() => { + mockAxios.reset(); + }); + + test("renders GameConfig",async () => { + render( + + + + + + ); + + expect(screen.getByText(/Cómo jugar/i)).toBeInTheDocument(); + const preElements = document.getElementsByTagName('pre'); + expect(preElements.length).toBe(3); + expect(preElements[0]).toHaveTextContent('Cuando inicies'); + expect(preElements[1]).toHaveTextContent('Cada vez que'); + expect(preElements[2]).toHaveTextContent('¡Demuestra'); + const ulElements = document.getElementsByTagName('ul'); + expect(ulElements.length).toBe(1); + const liElements = document.getElementsByTagName('li'); + expect(liElements.length).toBe(4); + expect(screen.getByText(/¡Demuestra tus conocimientos!/i)).toBeInTheDocument(); + }); + +}); +