From 06ad42381bc8c252b86d8b7a318cb391211cd078 Mon Sep 17 00:00:00 2001 From: Jack Carlisle Date: Wed, 24 Aug 2016 14:55:28 +0100 Subject: [PATCH] improves test coverage #540 --- lib/article-tile/test/index.test.js | 12 +++++++--- lib/beta-flag/test/index.test.js | 18 +++++++++++++++ lib/destination-tile/test/index.test.js | 4 ++++ lib/fade-image/test/index.test.js | 29 ++++++++++++++++++++++++ lib/hero-image-header/test/index.test.js | 7 +++++- 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 lib/beta-flag/test/index.test.js create mode 100644 lib/fade-image/test/index.test.js diff --git a/lib/article-tile/test/index.test.js b/lib/article-tile/test/index.test.js index a54009d..316c459 100644 --- a/lib/article-tile/test/index.test.js +++ b/lib/article-tile/test/index.test.js @@ -43,10 +43,16 @@ describe('Component', function () { }; describe('', function () { + const wrapper = shallow(); + const children = wrapper.children().nodes; it('should render our ArticleTile component', function (done) { - const wrapperTile = shallow(); - const childrenTile = wrapperTile.children().nodes; - expect(childrenTile).to.have.length(3); + expect(children).to.have.length(3); + done(); + }); + it('should render the correct child components', function (done) { + expect(wrapper.find('h2')).to.have.length(1); + expect(wrapper.find('h3')).to.have.length(1); + expect(wrapper.find('h4')).to.have.length(1); done(); }); }); diff --git a/lib/beta-flag/test/index.test.js b/lib/beta-flag/test/index.test.js new file mode 100644 index 0000000..f41a7ca --- /dev/null +++ b/lib/beta-flag/test/index.test.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { expect } from 'chai'; +import { shallow } from 'enzyme'; +import BetaFlag from '../'; + +describe('Component', function () { + const wrapper = shallow(); + const children = wrapper.children().nodes; + it('should render our component', function (done) { + expect(children).to.have.length(1); + done(); + }); + it('should render the correct child components', function (done) { + expect(wrapper.find('div')).to.have.length(1); + expect(wrapper.find('p')).to.have.length(1); + done(); + }); +}); diff --git a/lib/destination-tile/test/index.test.js b/lib/destination-tile/test/index.test.js index 7191fc0..090d0a1 100644 --- a/lib/destination-tile/test/index.test.js +++ b/lib/destination-tile/test/index.test.js @@ -25,6 +25,10 @@ describe('Component', function () { expect(children).to.have.length(1); done(); }); + it('should render the correct children', function (done) { + expect(wrapper.find('div')).to.have.length(12); + done(); + }); it('should render our video component if there is a url', function (done) { expect(wrapper.find('ReactPlayer')).to.have.length(1); done(); diff --git a/lib/fade-image/test/index.test.js b/lib/fade-image/test/index.test.js new file mode 100644 index 0000000..b24b934 --- /dev/null +++ b/lib/fade-image/test/index.test.js @@ -0,0 +1,29 @@ +import React from 'react'; +import { expect } from 'chai'; +import { shallow } from 'enzyme'; +import FadeImage from '../'; + +const props = { + isBackground: true +}; + +describe('Component', function () { + it('should render our component', function (done) { + const wrapper = shallow(); + const children = wrapper.children().nodes; + expect(children).to.have.length(0); + done(); + }); + it('should render a div if isBackground prop is true', function (done) { + const wrapper = shallow(); + expect(wrapper.find('div')).to.have.length(1); + expect(wrapper.find('img')).to.have.length(0); + done(); + }); + it('should render an img if isBackground prop is false', function (done) { + const wrapper = shallow(); + expect(wrapper.find('img')).to.have.length(1); + expect(wrapper.find('div')).to.have.length(0); + done(); + }); +}); diff --git a/lib/hero-image-header/test/index.test.js b/lib/hero-image-header/test/index.test.js index aacc620..bbc9d3b 100644 --- a/lib/hero-image-header/test/index.test.js +++ b/lib/hero-image-header/test/index.test.js @@ -4,11 +4,16 @@ import { expect } from 'chai'; import Header from '../'; describe('Component', function () { + const wrapper = shallow(
); describe('
', function () { it('Should render Header component', function (done) { - const wrapper = shallow(
); expect(wrapper.find('.headerBarWrapper')).to.have.length(1); done(); }); + it.only('should render the correct children', function (done) { + expect(wrapper.find('div')).to.have.length(3); + expect(wrapper.find('h1')).to.have.length(1); + done(); + }); }); });