Unit tests for App,Header,Inbox,MyTask,Dashboard components

This commit is contained in:
2018-04-12 09:53:15 +02:00
parent d19137a6f6
commit 57cbb68a6d
13 changed files with 224 additions and 10 deletions

View File

@@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Sutask io</title>
</head>
<body>
<noscript>

View File

@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "Subtask IO",
"name": "Subtask",
"icons": [
{
"src": "favicon.ico",

View File

@@ -1,9 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {MemoryRouter as Router} from 'react-router-dom'
import App from './index';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.render(<Router><App/></Router>, div);
ReactDOM.unmountComponentAtNode(div);
});

View File

@@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dummy renders correctly 1`] = `
<div
className={undefined}
>
<div
className={undefined}
>
<h1>
SUBTASK
</h1>
<div
className={undefined}
>
<a
className={undefined}
href="/mytask"
onClick={[Function]}
>
My Task
</a>
<a
className={undefined}
href="/inbox"
onClick={[Function]}
>
Inbox
</a>
<a
className={undefined}
href="/dashboard"
onClick={[Function]}
>
Dashboard
</a>
</div>
</div>
Dashboard
</div>
`;

View File

@@ -1,5 +1,5 @@
import React from 'react';
import {BrowserRouter as Router} from 'react-router-dom'
import {MemoryRouter as Router} from 'react-router-dom'
import Dashboard from './index';
import renderer from 'react-test-renderer';

View File

@@ -0,0 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dummy renders correctly 1`] = `
<div
className={undefined}
>
<h1>
SUBTASK
</h1>
<div
className={undefined}
>
<a
className={undefined}
href="/mytask"
onClick={[Function]}
>
My Task
</a>
<a
className={undefined}
href="/inbox"
onClick={[Function]}
>
Inbox
</a>
<a
className={undefined}
href="/dashboard"
onClick={[Function]}
>
Dashboard
</a>
</div>
</div>
`;

View File

@@ -0,0 +1,12 @@
import React from 'react';
import {MemoryRouter as Router} from 'react-router-dom'
import Header from './index';
import renderer from 'react-test-renderer';
test('Dummy renders correctly', () => {
const component = renderer.create(
<Router><Header/></Router>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

View File

@@ -1,11 +1,15 @@
import React from 'react';
import {Link } from 'react-router-dom'
import { Link } from 'react-router-dom'
import styles from './styles.scss';
const Header = () => {
return <div>
<Link to="/mytask">My Task</Link>
<Link to="/inbox">Inbox</Link>
<Link to="/dashboard">Dashboard</Link>
return <div className={styles.Header}>
<h1>SUBTASK</h1>
<div className={styles.HeaderContainer}>
<Link className={styles.HeaderContainer} to="/mytask">My Task</Link>
<Link className={styles.HeaderContainer} to="/inbox">Inbox</Link>
<Link className={styles.HeaderContainer} to="/dashboard">Dashboard</Link>
</div>
</div>;
};

View File

@@ -0,0 +1,14 @@
.Header {
padding-top : 12px;
padding-bottom : 12px;
display: flex;
justify-content: space-between;
align-items:center;
display: flex;
margin-left: 8px;
margin-right: 8px;
}
.HeaderContainer {
padding: 10px;
}

View File

@@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dummy renders correctly 1`] = `
<div
className={undefined}
>
<div
className={undefined}
>
<h1>
SUBTASK
</h1>
<div
className={undefined}
>
<a
className={undefined}
href="/mytask"
onClick={[Function]}
>
My Task
</a>
<a
className={undefined}
href="/inbox"
onClick={[Function]}
>
Inbox
</a>
<a
className={undefined}
href="/dashboard"
onClick={[Function]}
>
Dashboard
</a>
</div>
</div>
Inbox
</div>
`;

View File

@@ -0,0 +1,12 @@
import React from 'react';
import {MemoryRouter as Router} from 'react-router-dom'
import Inbox from './index';
import renderer from 'react-test-renderer';
test('Dummy renders correctly', () => {
const component = renderer.create(
<Router><Inbox/></Router>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

View File

@@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dummy renders correctly 1`] = `
<div
className={undefined}
>
<div
className={undefined}
>
<h1>
SUBTASK
</h1>
<div
className={undefined}
>
<a
className={undefined}
href="/mytask"
onClick={[Function]}
>
My Task
</a>
<a
className={undefined}
href="/inbox"
onClick={[Function]}
>
Inbox
</a>
<a
className={undefined}
href="/dashboard"
onClick={[Function]}
>
Dashboard
</a>
</div>
</div>
My Task
</div>
`;

View File

@@ -0,0 +1,12 @@
import React from 'react';
import {MemoryRouter as Router} from 'react-router-dom'
import MyTask from './index';
import renderer from 'react-test-renderer';
test('Dummy renders correctly', () => {
const component = renderer.create(
<Router><MyTask/></Router>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});