diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-07-19 21:00:30 +0100 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-07-20 09:47:42 +0200 |
| commit | 44875ed844de710e093ca8f5826d369f7ae0f410 (patch) | |
| tree | 2c43fae2cfb8c5cd81a85a6dbdfe2cf890749bb1 | |
| parent | 8c13b784a277db52f8100e3cd5bdea17f0736d1f (diff) | |
| download | mullvadvpn-44875ed844de710e093ca8f5826d369f7ae0f410.tar.xz mullvadvpn-44875ed844de710e093ca8f5826d369f7ae0f410.zip | |
Add SelectLocation tests
| -rw-r--r-- | test/components/SelectLocation.spec.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js new file mode 100644 index 0000000000..f25338dc47 --- /dev/null +++ b/test/components/SelectLocation.spec.js @@ -0,0 +1,50 @@ +// @flow + +import { expect } from 'chai'; +import React from 'react'; +import ReactTestUtils, { Simulate } from 'react-dom/test-utils'; +import SelectLocation from '../../app/components/SelectLocation'; +import { defaultServer } from '../../app/config'; + +import type { SettingsReduxState } from '../../app/redux/settings/reducers'; +import type { SelectLocationProps } from '../../app/components/SelectLocation'; + +describe('components/Account', () => { + const state: SettingsReduxState = { + autoSecure: true, + preferredServer: defaultServer + }; + + const makeProps = (state: SettingsReduxState, mergeProps: $Shape<SelectLocationProps>): SelectLocationProps => { + const defaultProps: SelectLocationProps = { + settings: state, + onClose: () => {}, + onSelect: (_server) => {} + }; + return Object.assign({}, defaultProps, mergeProps); + }; + + const render = (props: SelectLocationProps): SelectLocation => { + return ReactTestUtils.renderIntoDocument( + <SelectLocation { ...props } /> + ); + }; + + it('should call close callback', (done) => { + const props = makeProps(state, { + onClose: () => done() + }); + const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(render(props), 'select-location__close'); + Simulate.click(domNode); + }); + + it('should call select callback', (done) => { + const props = makeProps(state, { + onSelect: (_server) => done() + }); + const elements = ReactTestUtils.scryRenderedDOMComponentsWithClass(render(props), 'select-location__cell'); + expect(elements).to.have.length.greaterThan(0); + Simulate.click(elements[0]); + }); + +});
\ No newline at end of file |
