Skip to content

Commit

Permalink
[#68] Tests renamed .spec. into .test. (#89)
Browse files Browse the repository at this point in the history
* Fixed modal background
* Test backported
* Times set to 2 sec
* Word wrap + metadata
  • Loading branch information
mfrydrychowicz authored Jan 18, 2021
1 parent 9f9acd2 commit 55fb84a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 85 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>CodersCamp2020 | Star Wars API QUIZ</title>
<link rel="stylesheet" href="styles/App.scss"/>

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
</head>
Expand Down
66 changes: 1 addition & 65 deletions src/app/App.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,5 @@
import { doc } from 'prettier';
import { startTime } from './logic/timer';
import { generateQuestion } from './logic/generatingQuestions/generateQuestion';
import { modalGameOver } from './components/modalGameOver';
import { computerAnswers, mainWindow, playerAnswers } from './components/mainWindow';

const testDataHuman = [
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/1.jpg',
},
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/10.jpg',
},
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/10.jpg',
},
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/10.jpg',
},
];

const testDataComputer = [
{
answer: 'Test2',
correct: 'Test',
isCorrect: false,
img: '../../static/assets/img/modes/people/1.jpg',
},
{
answer: 'Test2',
correct: 'Test',
isCorrect: false,
img: '../../static/assets/img/modes/people/10.jpg',
},
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/10.jpg',
},
{
answer: 'Test',
correct: 'Test',
isCorrect: true,
img: '../../static/assets/img/modes/people/10.jpg',
},
];


const modalSubmitCallback = (e) => {
e.preventDefault();
console.log('MAY THE FORCE BE WITH YOU!');
document.querySelector('.swquiz-modal').style.display = 'none';
};
import { mainWindow } from './components/mainWindow';

export const App = ({ options }) => {
mainWindow(options.quizMaxTime);
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function fillMainWindowHTML() {
);
let quizGameFooter = createDiv(
'swquiz-game-footer'
)
);

quizGame.appendChild(quizGameHeader);
quizGame.appendChild(quizGameBody);
Expand All @@ -46,11 +46,11 @@ async function mainWindow(maxTime) {
redButton('play the game');
whiteButton('static/assets/icons/contacts_24px.svg', 'Hall of fame');
gameMode('Who is this Character?');
const default64Image = await getImage('people', 36)
imageRecognizer(default64Image)
const default64Image = await getImage('people', 36);
imageRecognizer(default64Image);
renderRules(getGameMode());

quiz(15000) // pass maxTime - this is only for testing
quiz(maxTime);
}

export { mainWindow };
4 changes: 3 additions & 1 deletion src/app/components/modalGameOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ const modalGameOver = (parent, playerAnswers, computerAnswers, callback) => {
modal.setAttribute('data-testid', 'gameOverModal');
if (modal) {
const appContainer = document.querySelector('#swquiz-app');
appContainer.classList.add('modal-overlay');
let modalOverlay = document.createElement('div');
modalOverlay.classList.add('modal-overlay');
appContainer.appendChild(modalOverlay);
}
parent.appendChild(modal);
createHeader(modal, 'Game Over');
Expand Down
1 change: 0 additions & 1 deletion src/app/components/whiteButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const whiteButton = (icone , text) => {
console.log(`${icone} ${text}`);
const app = document.getElementById('swquiz-game-footer-left');
const button = document.createElement('button');
const paragraph = document.createElement("p");
Expand Down
6 changes: 2 additions & 4 deletions styles/components/modalGameOver.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
justify-content: space-evenly;
font-size: 1.5em;
padding: 3vw;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1050;

Expand Down Expand Up @@ -66,6 +63,7 @@
justify-content: space-evenly;
margin: 20px 0 20px;
td {
word-wrap: anywhere;
width: 25%;
display: flex;
justify-content: center;
Expand Down Expand Up @@ -131,7 +129,7 @@

@media screen and (max-width:1023px){
.swquiz-modal{
height: 90vh;

font-size:2.5vw;
justify-content: space-between;
&--middleContainer{
Expand Down
27 changes: 27 additions & 0 deletions test/mainMenu.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { mainMenu } from '../src/app/components/mainMenu';
import { screen } from '@testing-library/dom';
import '@testing-library/jest-dom/extend-expect';

test('Adding nav element to DOM.', () => {
const getData = (element) => {
return element;
};
mainMenu(document.body, getData);
expect(screen.getByTestId('menuContainer')).toHaveClass('swquiz-menu');
expect(screen.getByTestId('menuContainer')).toBeInstanceOf(HTMLElement);
});

test('Throw error when provided invalid parent argument', () => {
const getData = (element) => {
return element;
};
expect(function () {
mainMenu(document.bodysss, getData);
}).toThrow(new TypeError("First argument isn't an object!"));
});

test('Throw error when provided invalid callback argument', () => {
expect(function () {
mainMenu(document.body, 'getData');
}).toThrow(new TypeError("Callback argument isn't a function!"));
});
9 changes: 0 additions & 9 deletions test/sampleJavaScript.spec.js

This file was deleted.

0 comments on commit 55fb84a

Please sign in to comment.