summaryrefslogtreecommitdiffhomepage
path: root/test/components/Switch.spec.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-01 16:13:10 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-05 12:11:55 +0200
commitca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch)
treeb1f7754eb50896ab3681e35fa4e08be642b940c9 /test/components/Switch.spec.js
parent5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff)
downloadmullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz
mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip
Add formatted source code
Diffstat (limited to 'test/components/Switch.spec.js')
-rw-r--r--test/components/Switch.spec.js44
1 files changed, 16 insertions, 28 deletions
diff --git a/test/components/Switch.spec.js b/test/components/Switch.spec.js
index eaac6dc08c..e1242d74df 100644
--- a/test/components/Switch.spec.js
+++ b/test/components/Switch.spec.js
@@ -7,16 +7,15 @@ import ReactTestUtils, { Simulate } from 'react-dom/test-utils';
import Switch from '../../app/components/Switch';
describe('components/Switch', () => {
-
let container: ?HTMLElement;
function renderIntoDocument(instance: React.Element<*>): React.Component<*, *> {
- if(container) {
+ if (container) {
throw new Error('Unmount previously rendered component first.');
}
container = document.createElement('div');
- if(!document.documentElement) {
+ if (!document.documentElement) {
throw new Error('document.documentElement cannot be null.');
}
@@ -27,7 +26,7 @@ describe('components/Switch', () => {
// unmount container and clean up DOM
afterEach(() => {
- if(container) {
+ if (container) {
ReactDOM.unmountComponentAtNode(container);
container = null;
}
@@ -38,12 +37,10 @@ describe('components/Switch', () => {
expect(isOn).to.be.true;
done();
};
- const component = renderIntoDocument(
- <Switch isOn={ false } onChange={ onChange } />
- );
+ const component = renderIntoDocument(<Switch isOn={false} onChange={onChange} />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'input');
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
Simulate.mouseDown(domNode, { clientX: 100, clientY: 0 });
Simulate.mouseUp(domNode, { clientX: 100, clientY: 0 });
Simulate.change(domNode, { target: { checked: true } });
@@ -55,12 +52,10 @@ describe('components/Switch', () => {
expect(isOn).to.be.false;
done();
};
- const component = renderIntoDocument(
- <Switch isOn={ true } onChange={ onChange } />
- );
+ const component = renderIntoDocument(<Switch isOn={true} onChange={onChange} />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'input');
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
Simulate.mouseDown(domNode, { clientX: 100, clientY: 0 });
Simulate.mouseUp(domNode, { clientX: 100, clientY: 0 });
Simulate.change(domNode, { target: { checked: false } });
@@ -72,12 +67,10 @@ describe('components/Switch', () => {
expect(isOn).to.be.true;
done();
};
- const component = renderIntoDocument(
- <Switch isOn={ false } onChange={ onChange } />
- );
+ const component = renderIntoDocument(<Switch isOn={false} onChange={onChange} />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'input');
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
Simulate.mouseDown(domNode, { clientX: 100, clientY: 0 });
}
@@ -91,13 +84,11 @@ describe('components/Switch', () => {
expect(isOn).to.be.false;
done();
};
- const component = renderIntoDocument(
- <Switch isOn={ true } onChange={ onChange } />
- );
+ const component = renderIntoDocument(<Switch isOn={true} onChange={onChange} />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'input');
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
Simulate.mouseDown(domNode, { clientX: 150, clientY: 0 });
}
@@ -111,13 +102,11 @@ describe('components/Switch', () => {
throw new Error('onChange should not be called on timeout.');
};
- const component = renderIntoDocument(
- <Switch isOn={ false } onChange={ onChange } />
- );
+ const component = renderIntoDocument(<Switch isOn={false} onChange={onChange} />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'input');
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
Simulate.mouseDown(domNode, { clientX: 100, clientY: 0 });
}
@@ -127,15 +116,14 @@ describe('components/Switch', () => {
try {
// See: https://github.com/facebook/flow/pull/5841
- if(domNode) {
+ if (domNode) {
// should not trigger onChange()
Simulate.change(domNode);
}
done();
- } catch(e) {
+ } catch (e) {
done(e);
}
}, 1000);
});
-
-}); \ No newline at end of file
+});