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 @@ ...@@ -5738,9 +5738,9 @@
"integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ==" "integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ=="
}, },
"handlebars": { "handlebars": {
"version": "4.2.0", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.1.tgz",
"integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==", "integrity": "sha512-c0HoNHzDiHpBt4Kqe99N8tdLPKAnGCQ73gYMPWtAYM4PwGnf7xl8PBUHJqh9ijlzt2uQKaSRxbXRt+rZ7M2/kA==",
"requires": { "requires": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
"optimist": "^0.6.1", "optimist": "^0.6.1",
...@@ -6939,7 +6939,7 @@ ...@@ -6939,7 +6939,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"minimatch": "3.0.4" "minimatch": "^3.0.4"
} }
}, },
"inflight": { "inflight": {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"
}, },
"browserslist": { "browserslist": {
"production": [ "production": [
">0.2%", ">0.2%",
......
import React from 'react'; import React from 'react';
import App from '../App'; import App from '../App';
import { create } from 'react-test-renderer' import renderer from 'react-test-renderer'
describe('My first snapshot test',()=>{ describe('Testing App.js',()=>{
test('testing App.js', () => {
let tree = create(<App />) test('Snapshot match test', () => {
expect(tree.toJSON()).toMatchSnapshot(); 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'; ...@@ -3,21 +3,6 @@ import MiddlePart from '../components/MiddlePart';
import { create } from 'react-test-renderer' import { create } from 'react-test-renderer'
describe('Testing the index state',()=>{ describe('Testing the index state',()=>{
beforeAll(() => {
})
afterAll(() => {
})
beforeEach(() => {
})
afterEach(() => {
})
test('testing if the index state variable increments when the nextButton is pressed', () => { test('testing if the index state variable increments when the nextButton is pressed', () => {
let tree = create(<MiddlePart />) let tree = create(<MiddlePart />)
...@@ -29,8 +14,6 @@ describe('Testing the index state',()=>{ ...@@ -29,8 +14,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(1); expect(instance.state.currentIndex).toBe(1);
expect(tree.toJSON()).toMatchSnapshot()
}) })
test('testing if the index state variable deincrements when the prevButton is pressed', () => { test('testing if the index state variable deincrements when the prevButton is pressed', () => {
...@@ -43,8 +26,6 @@ describe('Testing the index state',()=>{ ...@@ -43,8 +26,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(3); 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.', () => { 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',()=>{ ...@@ -57,8 +38,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(0); 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.', () => { 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',()=>{ ...@@ -71,8 +50,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(1); 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.', () => { 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',()=>{ ...@@ -85,8 +62,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(2); 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.', () => { 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',()=>{ ...@@ -99,8 +74,6 @@ describe('Testing the index state',()=>{
// currentIndex property is updated to `true` // currentIndex property is updated to `true`
expect(instance.state.currentIndex).toBe(3); expect(instance.state.currentIndex).toBe(3);
expect(tree.toJSON()).toMatchSnapshot()
}) })
}) })
\ No newline at end of file
// Jest Snapshot v1, https://goo.gl/fbAQLP // 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> <div>
<div <div
...@@ -33,6 +33,20 @@ exports[`My first snapshot test testing App.js 1`] = ` ...@@ -33,6 +33,20 @@ exports[`My first snapshot test testing App.js 1`] = `
</button> </button>
</div> </div>
<div
style={
Object {
"display": "flex",
}
}
>
<button
className="nextBtn"
onClick={[Function]}
>
</button>
</div>
<div <div
className="screenBoxWrapper" className="screenBoxWrapper"
> >
...@@ -52,7 +66,25 @@ exports[`My first snapshot test testing App.js 1`] = ` ...@@ -52,7 +66,25 @@ exports[`My first snapshot test testing App.js 1`] = `
> >
<div <div
className="box image" 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 <div
style={ style={
Object { Object {
...@@ -61,81 +93,185 @@ exports[`My first snapshot test testing App.js 1`] = ` ...@@ -61,81 +93,185 @@ exports[`My first snapshot test testing App.js 1`] = `
} }
> >
<div <div
className="box image" className="box sound"
id="svg-container"
> >
<img <audio
alt="BILDE" controls={true}
className="picture" src="Cat.mp3"
src="img1.jpg" type="audio/mpeg"
/> />
</div> </div>
</div> </div>
</div> </div>
<div </div>
className="container col" </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 <div
className="box text" className="radio"
> >
<div <label>
style={ <input
Object { checked={false}
"display": "flex", onChange={[Function]}
} type="radio"
} value="laugh"
> />
<div Laugh
className="box text" </label>
>
<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>
<div <div
className="box sound" className="radio"
> >
<div <label>
style={ <input
Object { checked={false}
"display": "flex", onChange={[Function]}
} type="radio"
} value="elevator"
> />
<div Elevator music
className="box sound" </label>
>
<audio
controls={true}
src="Cat.mp3"
type="audio/mpeg"
/>
</div>
</div>
</div> </div>
</div> </form>
</div> </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> </div>
<div
style={
Object {
"display": "flex",
}
}
>
<button
className="nextBtn"
onClick={[Function]}
>
</button>
</div>
<div <div
style={ style={
Object { Object {
...@@ -161,66 +297,5 @@ exports[`My first snapshot test testing App.js 1`] = ` ...@@ -161,66 +297,5 @@ exports[`My first snapshot test testing App.js 1`] = `
/> />
</div> </div>
</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> </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"