diff --git a/frontend/package.json b/frontend/package.json index 0453a21..1de398f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -62,6 +62,7 @@ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive" }, "jest": { + "setupTestFrameworkScriptFile": "/src/setupTests.js", "collectCoverageFrom": [ "src/**/*.{js,jsx,mjs}" ], diff --git a/frontend/src/components/App/Dashboard/__snapshots__/dashboard.test.js.snap b/frontend/src/components/App/Dashboard/__snapshots__/dashboard.test.js.snap index 9f5e9f8..74ccf73 100644 --- a/frontend/src/components/App/Dashboard/__snapshots__/dashboard.test.js.snap +++ b/frontend/src/components/App/Dashboard/__snapshots__/dashboard.test.js.snap @@ -1,41 +1,111 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Dummy renders correctly 1`] = ` -
-
-

- SUBTASK -

-
- - My Task - - - Inbox - - - Dashboard - -
-
- Dashboard -
+exports[`Daoardshb renders correctly 1`] = ` +ShallowWrapper { + "length": 1, + Symbol(enzyme.__root__): [Circular], + Symbol(enzyme.__unrendered__): + + , + Symbol(enzyme.__renderer__): Object { + "batchedUpdates": [Function], + "getNode": [Function], + "render": [Function], + "simulateEvent": [Function], + "unmount": [Function], + }, + Symbol(enzyme.__node__): Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "Dashboard", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + Symbol(enzyme.__nodes__): Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "Dashboard", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + ], + Symbol(enzyme.__options__): Object { + "adapter": ReactSixteenAdapter { + "options": Object { + "enableComponentDidUpdateOnSetState": true, + }, + }, + }, +} `; diff --git a/frontend/src/components/App/Dashboard/dashboard.test.js b/frontend/src/components/App/Dashboard/dashboard.test.js index 2dc9376..735e1b8 100644 --- a/frontend/src/components/App/Dashboard/dashboard.test.js +++ b/frontend/src/components/App/Dashboard/dashboard.test.js @@ -1,20 +1,13 @@ import React from 'react'; -import {MemoryRouter as Router} from 'react-router-dom' -import Dashboard from './index'; -import {mount} from 'enzyme' +import {HashRouter as Router} from 'react-router-dom' +import {Dashboard} from './index'; +import {shallow} from 'enzyme' import renderer from 'react-test-renderer'; -test('Dummy renders correctly', () => { - +test('Daoardshb renders correctly', () => { const props = { - title: 'Dashboard', + title: 'Dashboard' } - - - // // const component = renderer.create( - // , - // ); - const component = mount(()) - let tree = component.toJSON(); - expect(tree).toMatchSnapshot(); + const component = shallow(()) + expect(component).toMatchSnapshot(); }); \ No newline at end of file diff --git a/frontend/src/components/App/Dashboard/index.js b/frontend/src/components/App/Dashboard/index.js index f0a2092..6c7c918 100644 --- a/frontend/src/components/App/Dashboard/index.js +++ b/frontend/src/components/App/Dashboard/index.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux' import styles from './styles.scss'; import Header from '../Header/index' -const Dashboard = (props) => { +export const Dashboard = (props) => { return
Title {props.title}
; }; diff --git a/frontend/src/components/App/Header/__snapshots__/header.test.js.snap b/frontend/src/components/App/Header/__snapshots__/header.test.js.snap index 177aa56..12e081e 100644 --- a/frontend/src/components/App/Header/__snapshots__/header.test.js.snap +++ b/frontend/src/components/App/Header/__snapshots__/header.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Dummy renders correctly 1`] = ` +exports[`Header renders correctly 1`] = `
@@ -12,21 +12,21 @@ exports[`Dummy renders correctly 1`] = ` > My Task Inbox Dashboard diff --git a/frontend/src/components/App/Header/header.test.js b/frontend/src/components/App/Header/header.test.js index bc812bf..09280f8 100644 --- a/frontend/src/components/App/Header/header.test.js +++ b/frontend/src/components/App/Header/header.test.js @@ -1,9 +1,9 @@ import React from 'react'; -import {MemoryRouter as Router} from 'react-router-dom' +import {HashRouter as Router} from 'react-router-dom' import Header from './index'; import renderer from 'react-test-renderer'; -test('Dummy renders correctly', () => { +test('Header renders correctly', () => { const component = renderer.create(
, ); diff --git a/frontend/src/components/App/Header/index.js b/frontend/src/components/App/Header/index.js index 7f4c4e9..46308e5 100644 --- a/frontend/src/components/App/Header/index.js +++ b/frontend/src/components/App/Header/index.js @@ -2,13 +2,13 @@ import React from 'react'; import { Link } from 'react-router-dom' import styles from './styles.scss'; -const Header = () => { +export const Header = () => { return

SUBTASK

- My Task - Inbox - Dashboard + My Task + Inbox + Dashboard
; }; diff --git a/frontend/src/components/App/Inbox/__snapshots__/inbox.test.js.snap b/frontend/src/components/App/Inbox/__snapshots__/inbox.test.js.snap index deadfdf..d38b70e 100644 --- a/frontend/src/components/App/Inbox/__snapshots__/inbox.test.js.snap +++ b/frontend/src/components/App/Inbox/__snapshots__/inbox.test.js.snap @@ -1,41 +1,111 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Dummy renders correctly 1`] = ` -
+exports[`Inbox renders correctly 1`] = ` +ShallowWrapper { + "length": 1, + Symbol(enzyme.__root__): [Circular], + Symbol(enzyme.__unrendered__): + + , + Symbol(enzyme.__renderer__): Object { + "batchedUpdates": [Function], + "getNode": [Function], + "render": [Function], + "simulateEvent": [Function], + "unmount": [Function], + }, + Symbol(enzyme.__node__): Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "Inbox", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + Symbol(enzyme.__nodes__): Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "Inbox", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + ], + Symbol(enzyme.__options__): Object { + "adapter": ReactSixteenAdapter { + "options": Object { + "enableComponentDidUpdateOnSetState": true, + }, + }, + }, +} `; diff --git a/frontend/src/components/App/Inbox/inbox.test.js b/frontend/src/components/App/Inbox/inbox.test.js index a616ad9..c78065a 100644 --- a/frontend/src/components/App/Inbox/inbox.test.js +++ b/frontend/src/components/App/Inbox/inbox.test.js @@ -1,12 +1,13 @@ import React from 'react'; -import {MemoryRouter as Router} from 'react-router-dom' -import Inbox from './index'; +import {HashRouter as Router} from 'react-router-dom' +import {shallow} from 'enzyme' +import {Inbox} from './index'; import renderer from 'react-test-renderer'; -test('Dummy renders correctly', () => { - const component = renderer.create( - , - ); - let tree = component.toJSON(); - expect(tree).toMatchSnapshot(); +test('Inbox renders correctly', () => { + const props = { + title: 'Inbox' + } + const component = shallow(()) + expect(component).toMatchSnapshot(); }); \ No newline at end of file diff --git a/frontend/src/components/App/Inbox/index.js b/frontend/src/components/App/Inbox/index.js index 0665193..067fd6e 100644 --- a/frontend/src/components/App/Inbox/index.js +++ b/frontend/src/components/App/Inbox/index.js @@ -1,15 +1,15 @@ import React from 'react'; -import {connect} from 'react-redux' +import { connect } from 'react-redux' import styles from './styles.scss'; import Header from '../Header/index' -const Inbox = (props) => { - return
Title {props.title}
; +export const Inbox = (props) => { + return
Title {props.title}
; }; const mapStateToProps = (state) => { return { - title: state.pageInitialised.titles.title, + title: state.pageInitialised.titles.title, } } diff --git a/frontend/src/components/App/Mytask/__snapshots__/mytask.test.js.snap b/frontend/src/components/App/Mytask/__snapshots__/mytask.test.js.snap index 416ee81..fd81694 100644 --- a/frontend/src/components/App/Mytask/__snapshots__/mytask.test.js.snap +++ b/frontend/src/components/App/Mytask/__snapshots__/mytask.test.js.snap @@ -1,41 +1,111 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Dummy renders correctly 1`] = ` -
- - My Task -
+exports[`MyTask renders correctly 1`] = ` +ShallowWrapper { + "length": 1, + Symbol(enzyme.__root__): [Circular], + Symbol(enzyme.__unrendered__): + + , + Symbol(enzyme.__renderer__): Object { + "batchedUpdates": [Function], + "getNode": [Function], + "render": [Function], + "simulateEvent": [Function], + "unmount": [Function], + }, + Symbol(enzyme.__node__): Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "MyTask", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + Symbol(enzyme.__nodes__): Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": , + "history": Object { + "action": "POP", + "block": [Function], + "createHref": [Function], + "go": [Function], + "goBack": [Function], + "goForward": [Function], + "length": 1, + "listen": [Function], + "location": Object { + "hash": "", + "pathname": "/", + "search": "", + "state": undefined, + }, + "push": [Function], + "replace": [Function], + }, + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "title": "MyTask", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + "type": [Function], + }, + ], + Symbol(enzyme.__options__): Object { + "adapter": ReactSixteenAdapter { + "options": Object { + "enableComponentDidUpdateOnSetState": true, + }, + }, + }, +} `; diff --git a/frontend/src/components/App/Mytask/index.js b/frontend/src/components/App/Mytask/index.js index a6b4bdb..8921067 100644 --- a/frontend/src/components/App/Mytask/index.js +++ b/frontend/src/components/App/Mytask/index.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux' import styles from './styles.scss'; import Header from '../Header/index' -const MyTask = (props) => { +export const MyTask = (props) => { return
Title {props.title}
; }; diff --git a/frontend/src/components/App/Mytask/mytask.test.js b/frontend/src/components/App/Mytask/mytask.test.js index 570432c..a5aca3e 100644 --- a/frontend/src/components/App/Mytask/mytask.test.js +++ b/frontend/src/components/App/Mytask/mytask.test.js @@ -1,12 +1,14 @@ import React from 'react'; -import {MemoryRouter as Router} from 'react-router-dom' -import MyTask from './index'; +import {HashRouter as Router} from 'react-router-dom' +import {shallow} from 'enzyme' +import {MyTask} from './index'; import renderer from 'react-test-renderer'; -test('Dummy renders correctly', () => { - const component = renderer.create( - , - ); - let tree = component.toJSON(); - expect(tree).toMatchSnapshot(); +test('MyTask renders correctly', () => { + + const props = { + title: 'MyTask' + } + const component = shallow(()) + expect(component).toMatchSnapshot(); }); \ No newline at end of file diff --git a/frontend/src/index.js b/frontend/src/index.js index ab8be68..7c16073 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -10,6 +10,6 @@ import Root from './components/App/Root/index'; const store = createStore(subtaskIo) ReactDOM.render( - , + , document.getElementById('root')); registerServiceWorker(); diff --git a/frontend/src/setupTests.js b/frontend/src/setupTests.js new file mode 100644 index 0000000..82edfc9 --- /dev/null +++ b/frontend/src/setupTests.js @@ -0,0 +1,4 @@ +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() });