Skip to content

Commit

Permalink
improves test coverage #540
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcarlisle committed Aug 24, 2016
1 parent e866e8f commit 06ad423
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/article-tile/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ describe('Component', function () {
};

describe('<ArticleTile />', function () {
const wrapper = shallow(<ArticleTile {...props}/>);
const children = wrapper.children().nodes;
it('should render our ArticleTile component', function (done) {
const wrapperTile = shallow(<ArticleTile {...props}/>);
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();
});
});
Expand Down
18 changes: 18 additions & 0 deletions lib/beta-flag/test/index.test.js
Original file line number Diff line number Diff line change
@@ -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(<BetaFlag />);
const children = wrapper.children().nodes;
it('should render our <BetaFlag /> 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();
});
});
4 changes: 4 additions & 0 deletions lib/destination-tile/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 29 additions & 0 deletions lib/fade-image/test/index.test.js
Original file line number Diff line number Diff line change
@@ -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 <FadeImage /> component', function (done) {
const wrapper = shallow(<FadeImage {...props} />);
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(<FadeImage {...props} />);
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(<FadeImage isBackground={false} />);
expect(wrapper.find('img')).to.have.length(1);
expect(wrapper.find('div')).to.have.length(0);
done();
});
});
7 changes: 6 additions & 1 deletion lib/hero-image-header/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import { expect } from 'chai';
import Header from '../';

describe('Component', function () {
const wrapper = shallow(<Header displayedItems={[]}/>);
describe('<Header />', function () {
it('Should render Header component', function (done) {
const wrapper = shallow(<Header displayedItems={[]}/>);
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();
});
});
});

0 comments on commit 06ad423

Please sign in to comment.