This repository has been archived by the owner on May 10, 2024. It is now read-only.
generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from Arquisoft/against-the-clock
Against Clock
- Loading branch information
Showing
8 changed files
with
2,992 additions
and
1,796 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { React } from "react"; | ||
import Game from "./Game"; | ||
import PropTypes from "prop-types"; | ||
import {useLocation} from "react-router-dom"; | ||
|
||
export const AgainstClock = ({tags}) => { | ||
const token = localStorage.getItem('token'); | ||
|
||
const location = useLocation(); | ||
|
||
let gameTags = ""; | ||
|
||
if(tags !== undefined && tags !== null) { | ||
gameTags = tags; | ||
} | ||
if(location.state !== undefined && location.state !== null){ | ||
gameTags = location.state.tags; | ||
} | ||
|
||
return ( | ||
<Game | ||
name = "AgainstClock" | ||
tags = {gameTags} | ||
/> | ||
); | ||
|
||
|
||
} | ||
|
||
AgainstClock.propTypes = { | ||
tags: PropTypes.string.isRequired | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import {render, screen, fireEvent, act, waitFor} from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import {AgainstClock} from './AgainstClock'; | ||
import Game from "./Game"; | ||
import { MemoryRouter, Route } from 'react-router-dom'; | ||
import * as router from "react-router"; | ||
import "../../i18n"; | ||
|
||
jest.mock('../../services/game.service', () => ({ | ||
startNewGame: () => Promise.resolve(""), | ||
nextQuestion: () => Promise.resolve({ title: 'Pregunta de prueba', awnsers: ['Respuesta 1', 'Respuesta 2', 'Respuesta 3', 'Respuesta 4'] }), | ||
awnser: () => Promise.resolve('Respuesta 1'), | ||
getEndTime: () => Promise.resolve( | ||
{ | ||
end: 50, | ||
start: 0 | ||
} | ||
), | ||
getGameSettings: () => Promise.resolve({durationQuestion:50}), | ||
getNumberOfQuestions: () => Promise.resolve(10), | ||
getCurrentQuestion: () => Promise.resolve({ title: 'Pregunta actual', user_answer: 'Respuesta 1', answer: 'Respuesta 1' }), | ||
})); | ||
|
||
const navigate = jest.fn(); | ||
const locate = jest.fn(); | ||
|
||
describe("Game component", () => { | ||
beforeEach(() => { | ||
localStorage.setItem("token", "manolineldelpino"); | ||
jest.spyOn(router, 'useNavigate').mockImplementation(() => navigate) | ||
jest.spyOn(router, 'useLocation').mockImplementation(() => locate) | ||
}); | ||
|
||
test('renders component', async () => { | ||
await act(() => render(<AgainstClock tags={"tag"}/>)) | ||
|
||
expect(screen.getByText(/Pregunta de prueba/i)).toBeInTheDocument(); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters