summaryrefslogtreecommitdiffhomepage
path: root/test/components
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
parent5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff)
downloadmullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz
mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip
Add formatted source code
Diffstat (limited to 'test/components')
-rw-r--r--test/components/Account.spec.js23
-rw-r--r--test/components/AccountInput.spec.js37
-rw-r--r--test/components/Connect.spec.js19
-rw-r--r--test/components/HeaderBar.spec.js10
-rw-r--r--test/components/Login.spec.js13
-rw-r--r--test/components/Preferences.spec.js6
-rw-r--r--test/components/SelectLocation.spec.js69
-rw-r--r--test/components/Settings.spec.js42
-rw-r--r--test/components/Support.spec.js20
-rw-r--r--test/components/Switch.spec.js44
10 files changed, 129 insertions, 154 deletions
diff --git a/test/components/Account.spec.js b/test/components/Account.spec.js
index ccdb1d2117..c9d0891022 100644
--- a/test/components/Account.spec.js
+++ b/test/components/Account.spec.js
@@ -13,9 +13,9 @@ describe('components/Account', () => {
const state: AccountReduxState = {
accountToken: '1234',
accountHistory: [],
- expiry: (new Date('2038-01-01')).toISOString(),
+ expiry: new Date('2038-01-01').toISOString(),
status: 'none',
- error: null
+ error: null,
};
const makeProps = (state: AccountReduxState, mergeProps: $Shape<AccountProps>): AccountProps => {
@@ -23,14 +23,14 @@ describe('components/Account', () => {
account: state,
onClose: () => {},
onLogout: () => {},
- onBuyMore: () => {}
+ onBuyMore: () => {},
};
return Object.assign({}, defaultProps, mergeProps);
};
it('should call close callback', (done) => {
const props = makeProps(state, {
- onClose: () => done()
+ onClose: () => done(),
});
const component = getComponent(render(props), 'account__close');
click(component);
@@ -38,7 +38,7 @@ describe('components/Account', () => {
it('should call logout callback', (done) => {
const props = makeProps(state, {
- onLogout: () => done()
+ onLogout: () => done(),
});
const component = getComponent(render(props), 'account__logout');
click(component);
@@ -46,7 +46,7 @@ describe('components/Account', () => {
it('should call "buy more" callback', (done) => {
const props = makeProps(state, {
- onBuyMore: () => done()
+ onBuyMore: () => done(),
});
const component = getComponent(render(props), 'account__buymore');
click(component);
@@ -56,9 +56,9 @@ describe('components/Account', () => {
const expiredState: AccountReduxState = {
accountToken: '1234',
accountHistory: [],
- expiry: (new Date('2001-01-01')).toISOString(),
+ expiry: new Date('2001-01-01').toISOString(),
status: 'none',
- error: null
+ error: null,
};
const props = makeProps(expiredState, {});
const component = getComponent(render(props), 'account__out_of_time');
@@ -70,17 +70,14 @@ describe('components/Account', () => {
const component = getComponent(render(props), 'account__out_of_time');
expect(component).to.have.length(0);
});
-
});
function render(props) {
- return shallow(
- <Account {...props} />
- );
+ return shallow(<Account {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function click(component) {
diff --git a/test/components/AccountInput.spec.js b/test/components/AccountInput.spec.js
index a10326bc17..25f2e366b7 100644
--- a/test/components/AccountInput.spec.js
+++ b/test/components/AccountInput.spec.js
@@ -18,17 +18,15 @@ describe('components/AccountInput', () => {
const defaultProps: AccountInputProps = {
value: '',
onEnter: null,
- onChange: null
+ onChange: null,
};
const props = Object.assign({}, defaultProps, mergeProps);
- return shallow(
- <AccountInput {...props} />
- );
+ return shallow(<AccountInput {...props} />);
};
it('should call onEnter', (done) => {
const component = render({
- onEnter: () => done()
+ onEnter: () => done(),
});
keyPress(getInputRef(component), createKeyEvent('Enter'));
});
@@ -38,7 +36,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('1');
done();
- }
+ },
});
keyPress(getInputRef(component), createKeyEvent('1'));
});
@@ -58,10 +56,10 @@ describe('components/AccountInput', () => {
'111',
'11',
'1',
- ''
+ '',
];
- for(const value of cases) {
+ for (const value of cases) {
const component = render({ value });
expect(getInputRef(component).prop('value')).to.be.equal(value);
}
@@ -73,7 +71,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('123');
done();
- }
+ },
});
keyPress(getInputRef(component), createKeyEvent('Backspace'));
});
@@ -84,7 +82,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('234');
done();
- }
+ },
});
component.setState({ selectionRange: [1, 1] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -97,7 +95,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.empty;
done();
- }
+ },
});
component.setState({ selectionRange: [0, 8] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -110,7 +108,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('12349999');
done();
- }
+ },
});
component.setState({ selectionRange: [4, 8] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -119,7 +117,7 @@ describe('components/AccountInput', () => {
it('should replace selection', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
component.setState({ selectionRange: [1, 3] }, () => {
@@ -136,7 +134,7 @@ describe('components/AccountInput', () => {
it('should keep selection in the back', (done) => {
const component = render({ value: '' });
- for(let i = 0; i < 12; i++) {
+ for (let i = 0; i < 12; i++) {
keyPress(getInputRef(component), createKeyEvent('1'));
}
@@ -149,9 +147,9 @@ describe('components/AccountInput', () => {
it('should advance selection on insertion', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
- component.setState({ selectionRange: [1, 1]}, () => {
+ component.setState({ selectionRange: [1, 1] }, () => {
keyPress(getInputRef(component), createKeyEvent('1'));
component.setState({}, () => {
@@ -164,7 +162,7 @@ describe('components/AccountInput', () => {
it('should not do anything when nothing to remove', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
component.setState({ selectionRange: [0, 0] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -176,13 +174,12 @@ describe('components/AccountInput', () => {
});
});
});
-
});
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function keyPress(component, key) {
component.prop('onKeyPress')(key);
-} \ No newline at end of file
+}
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js
index 59079082c5..64771248b6 100644
--- a/test/components/Connect.spec.js
+++ b/test/components/Connect.spec.js
@@ -9,13 +9,12 @@ import Connect from '../../app/components/Connect';
import type { ConnectProps } from '../../app/components/Connect';
describe('components/Connect', () => {
-
it('shows unsecured hints when disconnected', () => {
const component = renderWithProps({
connection: {
...defaultProps.connection,
status: 'disconnected',
- }
+ },
});
const header = getComponent(component, 'header');
@@ -31,7 +30,7 @@ describe('components/Connect', () => {
connection: {
...defaultProps.connection,
status: 'connected',
- }
+ },
});
const header = getComponent(component, 'header');
@@ -49,7 +48,7 @@ describe('components/Connect', () => {
status: 'connecting',
country: 'Norway',
city: 'Oslo',
- }
+ },
});
const countryAndCity = getComponent(component, 'location');
const ipAddr = getComponent(component, 'ipAddress');
@@ -67,7 +66,7 @@ describe('components/Connect', () => {
country: 'Norway',
city: 'Oslo',
ip: '4.3.2.1',
- }
+ },
});
const countryAndCity = getComponent(component, 'location');
const ipAddr = getComponent(component, 'ipAddress');
@@ -85,7 +84,7 @@ describe('components/Connect', () => {
country: 'Norway',
city: 'Oslo',
ip: '4.3.2.1',
- }
+ },
});
const countryAndCity = getComponent(component, 'location');
const ipAddr = getComponent(component, 'ipAddress');
@@ -101,7 +100,7 @@ describe('components/Connect', () => {
connection: {
...defaultProps.connection,
status: 'disconnected',
- }
+ },
});
const connectButton = getComponent(component, 'secureConnection');
@@ -131,9 +130,9 @@ const defaultProps: ConnectProps = {
function renderWithProps(customProps: $Shape<ConnectProps>) {
const props = { ...defaultProps, ...customProps };
- return shallow( <Connect { ...props } /> );
+ return shallow(<Connect {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
-} \ No newline at end of file
+ return container.findWhere((n) => n.prop('testName') === testName);
+}
diff --git a/test/components/HeaderBar.spec.js b/test/components/HeaderBar.spec.js
index e4ebb09429..44731646d2 100644
--- a/test/components/HeaderBar.spec.js
+++ b/test/components/HeaderBar.spec.js
@@ -8,7 +8,6 @@ import HeaderBar from '../../app/components/HeaderBar';
require('../setup/enzyme');
describe('components/HeaderBar', () => {
-
it('should display headerbar', () => {
const component = render({
hidden: false,
@@ -44,22 +43,19 @@ describe('components/HeaderBar', () => {
it('should call settings callback', (done) => {
const component = render({
showSettings: true,
- onSettings: () => done(),
+ onSettings: () => done(),
});
const settingsButton = getComponent(component, 'headerbar__settings');
click(settingsButton);
});
-
});
function render(props) {
- return shallow(
- <HeaderBar {...props} />
- );
+ return shallow(<HeaderBar {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function hasChild(container, testName) {
diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js
index f8f4af54de..355e566d11 100644
--- a/test/components/Login.spec.js
+++ b/test/components/Login.spec.js
@@ -9,17 +9,16 @@ import Login from '../../app/components/Login';
import AccountInput from '../../app/components/AccountInput';
describe('components/Login', () => {
-
it('notifies on the first change after failure', () => {
let onFirstChange = sinon.spy();
const props = {
account: Object.assign({}, defaultAccount, {
- status: 'failed'
+ status: 'failed',
}),
onFirstChangeAfterFailure: onFirstChange,
};
- const component = renderWithProps( props );
+ const component = renderWithProps(props);
const accountInput = component.find(AccountInput);
accountInput.simulate('change', 'foo');
@@ -61,7 +60,7 @@ describe('components/Login', () => {
const component = renderNotLoggedIn();
component.setProps({
account: Object.assign({}, defaultAccount, {
- accountToken: '12345'
+ accountToken: '12345',
}),
onLogin: (an) => {
try {
@@ -82,7 +81,7 @@ const defaultAccount = {
accountHistory: [],
expiry: null,
status: 'none',
- error: null
+ error: null,
};
const defaultProps = {
@@ -122,11 +121,11 @@ function renderNotLoggedIn() {
function renderWithProps(customProps) {
const props = Object.assign({}, defaultProps, customProps);
- return shallow( <Login { ...props } /> );
+ return shallow(<Login {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function click(component) {
diff --git a/test/components/Preferences.spec.js b/test/components/Preferences.spec.js
index cad039df32..833a123538 100644
--- a/test/components/Preferences.spec.js
+++ b/test/components/Preferences.spec.js
@@ -8,15 +8,13 @@ import Preferences from '../../app/components/Preferences';
require('../setup/enzyme');
describe('components/Preferences', () => {
-
it('Should call close handler', (done) => {
const props = makeProps({ onClose: done });
- const component = shallow(<Preferences { ...props } />);
+ const component = shallow(<Preferences {...props} />);
const button = component.find({ testName: 'closeButton' });
expect(button).to.have.length(1);
button.simulate('press');
});
-
});
function makeProps(props) {
@@ -24,6 +22,6 @@ function makeProps(props) {
onClose: () => {},
onChangeAllowLan: () => {},
allowLan: false,
- ...props
+ ...props,
};
}
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js
index 4e2265c6dd..8310d52b97 100644
--- a/test/components/SelectLocation.spec.js
+++ b/test/components/SelectLocation.spec.js
@@ -15,47 +15,53 @@ describe('components/SelectLocation', () => {
location: 'any',
protocol: 'any',
port: 'any',
- }
+ },
},
- relayLocations: [{
- name: 'Sweden',
- code: 'se',
- hasActiveRelays: true,
- cities: [{
- name: 'Malmö',
- code: 'mma',
- latitude: 0,
- longitude: 0,
+ relayLocations: [
+ {
+ name: 'Sweden',
+ code: 'se',
hasActiveRelays: true,
- }, {
- name: 'Stockholm',
- code: 'sto',
- latitude: 0,
- longitude: 0,
- hasActiveRelays: true,
- }],
- }],
+ cities: [
+ {
+ name: 'Malmö',
+ code: 'mma',
+ latitude: 0,
+ longitude: 0,
+ hasActiveRelays: true,
+ },
+ {
+ name: 'Stockholm',
+ code: 'sto',
+ latitude: 0,
+ longitude: 0,
+ hasActiveRelays: true,
+ },
+ ],
+ },
+ ],
allowLan: false,
};
- const makeProps = (state: SettingsReduxState, mergeProps: $Shape<SelectLocationProps>): SelectLocationProps => {
+ const makeProps = (
+ state: SettingsReduxState,
+ mergeProps: $Shape<SelectLocationProps>,
+ ): SelectLocationProps => {
const defaultProps: SelectLocationProps = {
settings: state,
onClose: () => {},
- onSelect: (_server) => {}
+ onSelect: (_server) => {},
};
return Object.assign({}, defaultProps, mergeProps);
};
const render = (props: SelectLocationProps) => {
- return shallow(
- <SelectLocation { ...props } />
- );
+ return shallow(<SelectLocation {...props} />);
};
it('should call close callback', (done) => {
const props = makeProps(state, {
- onClose: () => done()
+ onClose: () => done(),
});
const node = getComponent(render(props), 'close');
click(node);
@@ -66,13 +72,13 @@ describe('components/SelectLocation', () => {
onSelect: (location) => {
try {
expect(location).to.deep.equal({
- country: 'se'
+ country: 'se',
});
done();
- } catch(e) {
+ } catch (e) {
done(e);
}
- }
+ },
});
const elements = getComponent(render(props), 'country');
expect(elements).to.have.length(1);
@@ -84,23 +90,22 @@ describe('components/SelectLocation', () => {
onSelect: (location) => {
try {
expect(location).to.deep.equal({
- city: ['se', 'mma']
+ city: ['se', 'mma'],
});
done();
- } catch(e) {
+ } catch (e) {
done(e);
}
- }
+ },
});
const elements = getComponent(render(props), 'city');
expect(elements).to.have.length(2);
click(elements.at(0));
});
-
});
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function click(component) {
diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js
index 8f0e4a73d4..447b0b50db 100644
--- a/test/components/Settings.spec.js
+++ b/test/components/Settings.spec.js
@@ -17,23 +17,23 @@ describe('components/Settings', () => {
accountHistory: [],
expiry: null,
status: 'none',
- error: null
+ error: null,
};
const loggedInAccountState: AccountReduxState = {
accountToken: '1234',
accountHistory: [],
- expiry: (new Date('2038-01-01')).toISOString(),
+ expiry: new Date('2038-01-01').toISOString(),
status: 'ok',
- error: null
+ error: null,
};
const unpaidAccountState: AccountReduxState = {
accountToken: '1234',
accountHistory: [],
- expiry: (new Date('2001-01-01')).toISOString(),
+ expiry: new Date('2001-01-01').toISOString(),
status: 'ok',
- error: null
+ error: null,
};
const settingsState: SettingsReduxState = {
@@ -48,7 +48,11 @@ describe('components/Settings', () => {
allowLan: false,
};
- const makeProps = (anAccountState: AccountReduxState, aSettingsState: SettingsReduxState, mergeProps: $Shape<SettingsProps> = {}): SettingsProps => {
+ const makeProps = (
+ anAccountState: AccountReduxState,
+ aSettingsState: SettingsReduxState,
+ mergeProps: $Shape<SettingsProps> = {},
+ ): SettingsProps => {
const defaultProps: SettingsProps = {
account: anAccountState,
settings: aSettingsState,
@@ -59,7 +63,7 @@ describe('components/Settings', () => {
onViewSupport: () => {},
onViewAdvancedSettings: () => {},
onViewPreferences: () => {},
- onExternalLink: (_type) => {}
+ onExternalLink: (_type) => {},
};
return Object.assign({}, defaultProps, mergeProps);
};
@@ -120,7 +124,7 @@ describe('components/Settings', () => {
it('should call close callback', (done) => {
const props = makeProps(loggedOutAccountState, settingsState, {
- onClose: () => done()
+ onClose: () => done(),
});
const component = getComponent(render(props), 'settings__close');
click(component);
@@ -128,7 +132,7 @@ describe('components/Settings', () => {
it('should call quit callback', (done) => {
const props = makeProps(loggedOutAccountState, settingsState, {
- onQuit: () => done()
+ onQuit: () => done(),
});
const component = getComponent(render(props), 'settings__quit');
click(component);
@@ -136,7 +140,7 @@ describe('components/Settings', () => {
it('should call account callback', (done) => {
const props = makeProps(loggedInAccountState, settingsState, {
- onViewAccount: () => done()
+ onViewAccount: () => done(),
});
const component = getComponent(render(props), 'settings__account_paid_until_button');
click(component);
@@ -144,7 +148,7 @@ describe('components/Settings', () => {
it('should call advanced settings callback', (done) => {
const props = makeProps(loggedInAccountState, settingsState, {
- onViewAdvancedSettings: () => done()
+ onViewAdvancedSettings: () => done(),
});
const component = getComponent(render(props), 'settings__advanced');
click(component);
@@ -152,7 +156,7 @@ describe('components/Settings', () => {
it('should call preferences callback', (done) => {
const props = makeProps(loggedInAccountState, settingsState, {
- onViewPreferences: () => done()
+ onViewPreferences: () => done(),
});
const component = getComponent(render(props), 'settings__preferences');
click(component);
@@ -160,7 +164,7 @@ describe('components/Settings', () => {
it('should call support callback', (done) => {
const props = makeProps(loggedInAccountState, settingsState, {
- onViewSupport: () => done()
+ onViewSupport: () => done(),
});
const component = getComponent(render(props), 'settings__view_support');
click(component);
@@ -171,25 +175,21 @@ describe('components/Settings', () => {
const props = makeProps(loggedOutAccountState, settingsState, {
onExternalLink: (type) => {
collectedExternalLinkTypes.push(type);
- }
+ },
});
const container = getComponent(render(props), 'settings__external_link');
- container.find({ testName: 'settings__external_link' })
- .forEach((element) => click(element));
+ container.find({ testName: 'settings__external_link' }).forEach((element) => click(element));
expect(collectedExternalLinkTypes).to.include.ordered.members(['faq', 'guides']);
});
-
});
function render(props) {
- return shallow(
- <Settings {...props} />
- );
+ return shallow(<Settings {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function click(component) {
diff --git a/test/components/Support.spec.js b/test/components/Support.spec.js
index a1a953fa2c..a968db974f 100644
--- a/test/components/Support.spec.js
+++ b/test/components/Support.spec.js
@@ -10,7 +10,6 @@ import sinon from 'sinon';
import type { SupportProps } from '../../app/components/Support';
describe('components/Support', () => {
-
const makeProps = (mergeProps: $Shape<SupportProps> = {}): SupportProps => {
const defaultProps: SupportProps = {
account: {
@@ -23,14 +22,14 @@ describe('components/Support', () => {
onClose: () => {},
onViewLog: (_path) => {},
onCollectLog: () => Promise.resolve('/tmp/mullvad_problem_report.log'),
- onSend: (_report) => {}
+ onSend: (_report) => {},
};
return Object.assign({}, defaultProps, mergeProps);
};
it('should call close callback', (done) => {
const props = makeProps({
- onClose: () => done()
+ onClose: () => done(),
});
const component = getComponent(render(props), 'support__close');
click(component);
@@ -38,7 +37,7 @@ describe('components/Support', () => {
it('should call view logs callback', (done) => {
const props = makeProps({
- onViewLog: (_path) => done()
+ onViewLog: (_path) => done(),
});
const component = getComponent(render(props), 'support__view_logs');
click(component);
@@ -46,7 +45,7 @@ describe('components/Support', () => {
it('should call send callback when description filled in', (done) => {
const props = makeProps({
- onSend: (_report) => done()
+ onSend: (_report) => done(),
});
const component = render(props);
@@ -68,7 +67,7 @@ describe('components/Support', () => {
it('should not collect report twice', (done) => {
const collectCallback = sinon.spy(() => Promise.resolve('non-falsy'));
const props = makeProps({
- onCollectLog: collectCallback
+ onCollectLog: collectCallback,
});
const viewLogButton = getComponent(render(props), 'support__view_logs');
@@ -99,7 +98,7 @@ describe('components/Support', () => {
} catch (e) {
done(e);
}
- }
+ },
});
const component = render(props);
@@ -108,17 +107,14 @@ describe('components/Support', () => {
const sendButton = getComponent(component, 'support__send_logs');
click(sendButton);
});
-
});
function render(props) {
- return shallow(
- <Support {...props} />
- );
+ return shallow(<Support {...props} />);
}
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function click(component) {
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
+});