summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-07-17 12:51:15 +0100
committerAndrej Mihajlov <and@codeispoetry.ru>2017-07-17 12:51:15 +0100
commitdfbc0383ed1fb27971268b21b71ee7b2ba348f47 (patch)
tree1b83b2d798efa0aa9a873393dd14bc029ba83067
parent8e0d786ac57b952ba49d9a452c00c2512ac0ea6f (diff)
parenta20a442774182219ef35266119b81761051621f2 (diff)
downloadmullvadvpn-dfbc0383ed1fb27971268b21b71ee7b2ba348f47.tar.xz
mullvadvpn-dfbc0383ed1fb27971268b21b71ee7b2ba348f47.zip
Merge branch 'headerbar-tests'
-rw-r--r--app/components/HeaderBar.js4
-rw-r--r--test/components/HeaderBar.spec.js48
2 files changed, 51 insertions, 1 deletions
diff --git a/app/components/HeaderBar.js b/app/components/HeaderBar.js
index bae3c4fddf..26e937ad23 100644
--- a/app/components/HeaderBar.js
+++ b/app/components/HeaderBar.js
@@ -13,8 +13,10 @@ export type HeaderBarProps = {
export default class HeaderBar extends Component {
props: HeaderBarProps;
static defaultProps: $Shape<HeaderBarProps> = {
+ style: 'default',
hidden: false,
- showSettings: false
+ showSettings: false,
+ onSettings: null
};
render(): React.Element<*> {
diff --git a/test/components/HeaderBar.spec.js b/test/components/HeaderBar.spec.js
new file mode 100644
index 0000000000..f739ed9ab0
--- /dev/null
+++ b/test/components/HeaderBar.spec.js
@@ -0,0 +1,48 @@
+// @flow
+
+import { expect } from 'chai';
+import React from 'react';
+import ReactTestUtils, { Simulate } from 'react-dom/test-utils';
+import HeaderBar from '../../app/components/HeaderBar';
+
+describe('components/HeaderBar', () => {
+
+ it('should display headerbar', () => {
+ const component = ReactTestUtils.renderIntoDocument(
+ <HeaderBar hidden={ false } />
+ );
+ ReactTestUtils.findRenderedDOMComponentWithClass(component, 'headerbar__container');
+ });
+
+ it('should not display headerbar', () => {
+ const component = ReactTestUtils.renderIntoDocument(
+ <HeaderBar hidden={ true } />
+ );
+ const domNodes = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'headerbar__container');
+ expect(domNodes.length).to.be.equal(0);
+ });
+
+ it('should display settings button', () => {
+ const component = ReactTestUtils.renderIntoDocument(
+ <HeaderBar showSettings={ true } />
+ );
+ ReactTestUtils.findRenderedDOMComponentWithClass(component, 'headerbar__settings');
+ });
+
+ it('should not display settings button', () => {
+ const component = ReactTestUtils.renderIntoDocument(
+ <HeaderBar showSettings={ false } />
+ );
+ const domNodes = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'headerbar__settings');
+ expect(domNodes.length).to.be.equal(0);
+ });
+
+ it('should call settings callback', (done) => {
+ const component = ReactTestUtils.renderIntoDocument(
+ <HeaderBar showSettings={ true } onSettings={ () => done() } />
+ );
+ const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'headerbar__settings');
+ Simulate.click(domNode);
+ });
+
+}); \ No newline at end of file