diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-12-20 11:32:55 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-12-20 11:34:21 +0100 |
| commit | 2aae380b0af018bf0187bb31fb0fedf6a457ebf1 (patch) | |
| tree | a8ad6ee12956d92e6257bea07dedc44063f3017f /test/components/HeaderBar.spec.js | |
| parent | 7b47ddf735af7f3d6065fb6c3ffea6e9ddfd86cb (diff) | |
| parent | 8b146934260739ae609791a1fb676d48ceb954c0 (diff) | |
| download | mullvadvpn-2aae380b0af018bf0187bb31fb0fedf6a457ebf1.tar.xz mullvadvpn-2aae380b0af018bf0187bb31fb0fedf6a457ebf1.zip | |
Merge backend and frontend repo master branches
Conflicts:
.gitignore
.travis.yml
README.md
Diffstat (limited to 'test/components/HeaderBar.spec.js')
| -rw-r--r-- | test/components/HeaderBar.spec.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/components/HeaderBar.spec.js b/test/components/HeaderBar.spec.js new file mode 100644 index 0000000000..e4ebb09429 --- /dev/null +++ b/test/components/HeaderBar.spec.js @@ -0,0 +1,71 @@ +// @flow + +import { expect } from 'chai'; +import React from 'react'; +import { shallow } from 'enzyme'; +import HeaderBar from '../../app/components/HeaderBar'; + +require('../setup/enzyme'); + +describe('components/HeaderBar', () => { + + it('should display headerbar', () => { + const component = render({ + hidden: false, + }); + const hasChildMatching = hasChild(component, 'headerbar__container'); + expect(hasChildMatching).to.be.true; + }); + + it('should not display headerbar', () => { + const component = render({ + hidden: true, + }); + const hasChildMatching = hasChild(component, 'headerbar__container'); + expect(hasChildMatching).to.be.false; + }); + + it('should display settings button', () => { + const component = render({ + showSettings: true, + }); + const hasChildMatching = hasChild(component, 'headerbar__settings'); + expect(hasChildMatching).to.be.true; + }); + + it('should not display settings button', () => { + const component = render({ + showSettings: false, + }); + const hasChildMatching = hasChild(component, 'headerbar__settings'); + expect(hasChildMatching).to.be.false; + }); + + it('should call settings callback', (done) => { + const component = render({ + showSettings: true, + onSettings: () => done(), + }); + const settingsButton = getComponent(component, 'headerbar__settings'); + click(settingsButton); + }); + +}); + +function render(props) { + return shallow( + <HeaderBar {...props} /> + ); +} + +function getComponent(container, testName) { + return container.findWhere( n => n.prop('testName') === testName); +} + +function hasChild(container, testName) { + return getComponent(container, testName).length > 0; +} + +function click(component) { + component.prop('onPress')(); +} |
