From 6b02dd5dab6262169fda4f785971db0a4e00bf7c Mon Sep 17 00:00:00 2001 From: Ralphvandodewaard Date: Tue, 13 Jun 2017 09:29:52 +0200 Subject: [PATCH] Added test for channel-header --- test/channel-header/index.test.js | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 test/channel-header/index.test.js diff --git a/test/channel-header/index.test.js b/test/channel-header/index.test.js new file mode 100644 index 00000000..40cc52a4 --- /dev/null +++ b/test/channel-header/index.test.js @@ -0,0 +1,111 @@ +/* eslint-env mocha */ +/* eslint react/jsx-filename-extension: [0] */ +import React from 'react'; +import chai, { expect } from 'chai'; +import { shallow } from 'enzyme'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; +import ChannelHeader from '../../src/channel-header'; +import getStyles from '../../src/channel-header/get-styles'; + +chai.use(sinonChai); + +describe('ChannelHeader', () => { + const props = { + style: {}, + textStyle: {}, + rightButtonStyle: {}, + leftButtonStyle: {}, + rightButton: null, + leftButton: null, + name: 'name' + }; + + beforeEach(() => { + global.navigator = { userAgent: 'all' }; + }); + + afterEach(() => { + global.navigator = undefined; + }); + + it('should always render a header element', () => { + const wrapper = shallow().dive(); + + expect(wrapper.find('header')).to.have.length(1); + }); + + it('should not render a div element if the leftButton prop is not passed', () => { + const wrapper = shallow().dive(); + + expect(wrapper.find('div')).to.have.length(0); + }); + + it('should render a div element if the leftButton prop is passed', () => { + props.leftButton =