From c0099fcc8fe41e92f0fc0b5a96989001b1941db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Mon, 2 Jan 2017 23:32:15 +0000 Subject: [PATCH] increase code coverage --- frontend/src/components/redirect/index.js | 8 +++---- frontend/src/components/section/index.js | 4 ++++ frontend/src/containers/project/section.js | 6 ++--- frontend/test/components/project-section.js | 19 ++++++++++++++++ frontend/test/components/service.js | 25 +++++++++++++++++++++ frontend/test/components/services.js | 25 +++++++++++++++++++++ 6 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 frontend/test/components/project-section.js create mode 100644 frontend/test/components/service.js create mode 100644 frontend/test/components/services.js diff --git a/frontend/src/components/redirect/index.js b/frontend/src/components/redirect/index.js index bfc71d3e..06813aa8 100644 --- a/frontend/src/components/redirect/index.js +++ b/frontend/src/components/redirect/index.js @@ -5,8 +5,6 @@ const { Redirect } = ReactRouter; -module.exports = (to) => () => { - return ( - - ); -}; +module.exports = (to) => () => ( + +); diff --git a/frontend/src/components/section/index.js b/frontend/src/components/section/index.js index 4ccfde16..a4579555 100644 --- a/frontend/src/components/section/index.js +++ b/frontend/src/components/section/index.js @@ -30,6 +30,10 @@ const Section = ({ )); const nameLinks = flatten(name.map((part, i) => { + if (!part.name) { + return null; + } + const link = ( {part.name} diff --git a/frontend/src/containers/project/section.js b/frontend/src/containers/project/section.js index 2362a783..cc7ab6fd 100644 --- a/frontend/src/containers/project/section.js +++ b/frontend/src/containers/project/section.js @@ -15,7 +15,7 @@ const { projectSectionsSelector } = selectors; -const OrgSection = ({ +const ProjectSection = ({ children, org = {}, project = {}, @@ -49,7 +49,7 @@ const OrgSection = ({ ); }; -OrgSection.propTypes = { +ProjectSection.propTypes = { children: React.PropTypes.node, org: PropTypes.org, project: PropTypes.project, @@ -66,4 +66,4 @@ const mapStateToProps = (state, { module.exports = connect( mapStateToProps -)(OrgSection); +)(ProjectSection); diff --git a/frontend/test/components/project-section.js b/frontend/test/components/project-section.js new file mode 100644 index 00000000..f67c4e0c --- /dev/null +++ b/frontend/test/components/project-section.js @@ -0,0 +1,19 @@ +const test = require('ava'); +const enzyme = require('enzyme'); +const React = require('react'); + +const create = require('../helpers/create'); + +const { + render +} = enzyme; + +const { + withIntl +} = create; + +test('renders without exploding', (t) => { + const Section = require('@containers/project/section').WrappedComponent; + const wrapper = render(withIntl(
)); + t.deepEqual(wrapper.length, 1); +}); diff --git a/frontend/test/components/service.js b/frontend/test/components/service.js new file mode 100644 index 00000000..ce66f865 --- /dev/null +++ b/frontend/test/components/service.js @@ -0,0 +1,25 @@ +const test = require('ava'); +const enzyme = require('enzyme'); +const React = require('react'); + +const create = require('../helpers/create'); + +const { + render +} = enzyme; + +const { + withIntl +} = create; + +test('renders without exploding', (t) => { + const Service = require('@containers/service').WrappedComponent; + const wrapper = render(withIntl()); + t.deepEqual(wrapper.length, 1); +}); + +test('renders connected without exploding', (t) => { + const Service = require('@containers/service'); + const wrapper = render(create()); + t.deepEqual(wrapper.length, 1); +}); diff --git a/frontend/test/components/services.js b/frontend/test/components/services.js new file mode 100644 index 00000000..3c4f3a34 --- /dev/null +++ b/frontend/test/components/services.js @@ -0,0 +1,25 @@ +const test = require('ava'); +const enzyme = require('enzyme'); +const React = require('react'); + +const create = require('../helpers/create'); + +const { + render +} = enzyme; + +const { + withIntl +} = create; + +test('renders without exploding', (t) => { + const Services = require('@containers/services').WrappedComponent; + const wrapper = render(withIntl()); + t.deepEqual(wrapper.length, 1); +}); + +test('renders connected without exploding', (t) => { + const Services = require('@containers/services'); + const wrapper = render(create()); + t.deepEqual(wrapper.length, 1); +});