Commit 48a65e2a authored by Haakon Gunleiksrud's avatar Haakon Gunleiksrud
Browse files

Added a snapshot test and cleaned the other test files.

parent 327648b3
......@@ -5738,9 +5738,9 @@
"integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ=="
},
"handlebars": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz",
"integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==",
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.1.tgz",
"integrity": "sha512-c0HoNHzDiHpBt4Kqe99N8tdLPKAnGCQ73gYMPWtAYM4PwGnf7xl8PBUHJqh9ijlzt2uQKaSRxbXRt+rZ7M2/kA==",
"requires": {
"neo-async": "^2.6.0",
"optimist": "^0.6.1",
......@@ -6939,7 +6939,7 @@
"bundled": true,
"optional": true,
"requires": {
"minimatch": "3.0.4"
"minimatch": "^3.0.4"
}
},
"inflight": {
......
......@@ -17,7 +17,6 @@
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
......
import React from 'react';
import App from '../App';
import { create } from 'react-test-renderer'
import renderer from 'react-test-renderer'
describe('My first snapshot test',()=>{
test('testing App.js', () => {
let tree = create(<App />)
expect(tree.toJSON()).toMatchSnapshot();
})
describe('Testing App.js',()=>{
test('Snapshot match test', () => {
const tree = renderer.create(<App />).toJSON();
expect(tree).toMatchSnapshot();
})
})
\ No newline at end of file
import React from 'react';
import Header from '../components/header.jsx';
import renderer from 'react-test-renderer'
describe('Testing header.jsx',()=>{
test('Snapshot match test', () => {
const tree = renderer.create(<Header />).toJSON();
expect(tree).toMatchSnapshot();
})
})
\ No newline at end of file
......@@ -3,21 +3,6 @@ import MiddlePart from '../components/MiddlePart';
import { create } from 'react-test-renderer'
describe('Testing the index state',()=>{
beforeAll(() => {
})
afterAll(() => {
})
beforeEach(() => {
})
afterEach(() => {
})
test('testing if the index state variable increments when the nextButton is pressed', () => {
let tree = create(<MiddlePart />)
......@@ -29,8 +14,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(1);
expect(tree.toJSON()).toMatchSnapshot()
})
test('testing if the index state variable deincrements when the prevButton is pressed', () => {
......@@ -43,8 +26,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(3);
expect(tree.toJSON()).toMatchSnapshot()
})
test('testing if the index state variable changes to 0 when the first navigation button is pressed.', () => {
......@@ -57,8 +38,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(0);
expect(tree.toJSON()).toMatchSnapshot()
})
test('testing if the index state variable changes to 1 when the second navigation button is pressed.', () => {
......@@ -71,8 +50,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(1);
expect(tree.toJSON()).toMatchSnapshot()
})
test('testing if the index state variable changes to 2 when the third navigation button is pressed.', () => {
......@@ -85,8 +62,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(2);
expect(tree.toJSON()).toMatchSnapshot()
})
test('testing if the index state variable changes to 3 when the fourth navigation button is pressed.', () => {
......@@ -99,8 +74,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(3);
expect(tree.toJSON()).toMatchSnapshot()
})
})
\ No newline at end of file
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`My first snapshot test testing App.js 1`] = `
exports[`Testing App.js Snapshot match test 1`] = `
<div>
<div>
<div
......@@ -33,6 +33,20 @@ exports[`My first snapshot test testing App.js 1`] = `
</button>
</div>
<div
style={
Object {
"display": "flex",
}
}
>
<button
className="nextBtn"
onClick={[Function]}
>
</button>
</div>
<div
className="screenBoxWrapper"
>
......@@ -52,7 +66,25 @@ exports[`My first snapshot test testing App.js 1`] = `
>
<div
className="box image"
id="svg-container"
/>
<div
className="container col"
>
<div>
<div
className="box text"
id="text-container"
>
<q>
</q>
<p>
-
</p>
</div>
</div>
<div
style={
Object {
......@@ -61,81 +93,185 @@ exports[`My first snapshot test testing App.js 1`] = `
}
>
<div
className="box image"
id="svg-container"
className="box sound"
>
<img
alt="BILDE"
className="picture"
src="img1.jpg"
<audio
controls={true}
src="Cat.mp3"
type="audio/mpeg"
/>
</div>
</div>
</div>
<div
className="container col"
>
</div>
</div>
</div>
<div
className="sidebar"
>
<div
className="sidebar"
>
<div
className="sidebarSounds"
>
<h5>
Sounds
</h5>
<form>
<label>
<input
checked={true}
onChange={[Function]}
type="radio"
value="animals"
/>
Animals
</label>
<div
className="box text"
className="radio"
>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box text"
>
<p>
Ernest Hemingway once wrote, “The world is a fine place, and worth fighting for.” I agree with the second part.
</p>
<q>
David Fincher
</q>
</div>
</div>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="laugh"
/>
Laugh
</label>
</div>
<div
className="box sound"
className="radio"
>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box sound"
>
<audio
controls={true}
src="Cat.mp3"
type="audio/mpeg"
/>
</div>
</div>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="elevator"
/>
Elevator music
</label>
</div>
</div>
</form>
</div>
<div
className="sidebarImages"
>
<h5>
Images
</h5>
<form>
<div
className="sidebar"
>
<label>
<input
checked={true}
onChange={[Function]}
type="radio"
value="pokemon"
/>
Pokemon
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="dragon"
/>
Dragon
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="cat"
/>
Cat
</label>
</div>
</form>
</div>
<div
className="sidebarText"
>
<h5>
Texts
</h5>
<form>
<div
className="sidebar"
>
<label>
<input
checked={true}
onChange={[Function]}
type="radio"
value="clicheQuotes"
/>
Inspo
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="mediaQuotes"
/>
Movie quotes
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="limericks"
/>
Limericks
</label>
</div>
</form>
</div>
<button
onClick={[Function]}
>
See combination
</button>
<div
id="count"
/>
<button
onClick={[Function]}
>
Save as favorite
</button>
<button
onClick={[Function]}
>
Get favorite
</button>
</div>
</div>
<div
style={
Object {
"display": "flex",
}
}
>
<button
className="nextBtn"
onClick={[Function]}
>
</button>
</div>
<div
style={
Object {
......@@ -161,66 +297,5 @@ exports[`My first snapshot test testing App.js 1`] = `
/>
</div>
</div>
<div
className="sidebar"
>
<div
className="sidebar"
>
<div
className="sidebarAnimals"
>
<h5>
Animals
</h5>
<form>
<div
className="sidebar"
>
<label>
<input
checked={true}
onChange={[Function]}
type="radio"
value="cat"
/>
Cat
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="horse"
/>
Horse
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
onChange={[Function]}
type="radio"
value="donkey"
/>
Donkey
</label>
</div>
</form>
</div>
</div>
</div>
<button
onClick={[Function]}
>
Click meeee!
</button>
</div>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Testing header.jsx Snapshot match test 1`] = `
<div
className="header"
id="header"
>
Bilder, tekst og lyd
<button
className="sidebarButton"
onClick={[Function]}
>
knapp
</button>
</div>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Testing the index state testing if the index state variable changes to 0 when the first navigation button is pressed. 1`] = `
<div
className="screenBox"
>
<div
style={
Object {
"display": "flex",
}
}
>
<button
className="prevBtn"
onClick={[Function]}
>
</button>
</div>
<div
className="screenBoxWrapper"
>
<div
className="container main"
>
<meta
content="width=device-width, initial-scale=1.0"
name="viewport"
/>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box image"
>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box image"
id="svg-container"
>
<img
alt="BILDE"
className="picture"
src="img1.jpg"
/>
</div>
</div>
</div>
<div
className="container col"
>
<div
className="box text"
>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box text"
>
<p>
Ernest Hemingway once wrote, “The world is a fine place, and worth fighting for.” I agree with the second part.
</p>
<q>
David Fincher
</q>
</div>
</div>
</div>
<div
className="box sound"
>
<div
style={
Object {
"display": "flex",
}
}
>
<div
className="box sound"
>
<audio
controls={true}
src="Cat.mp3"
type="audio/mpeg"
/>
</div>