diff options
| author | anderklander <anderklander@gmail.com> | 2018-03-23 08:41:31 +0100 |
|---|---|---|
| committer | anderklander <anderklander@gmail.com> | 2018-04-11 13:45:41 +0200 |
| commit | d0dcf31199cc3efa23645312fb9b5d2eb41a1d56 (patch) | |
| tree | 7934d818fe7e5ca50721a875c89c00aea7ac1637 /test/components | |
| parent | 70fb24b51b159195fb5ba5e854459ae47ab01f90 (diff) | |
| download | mullvadvpn-d0dcf31199cc3efa23645312fb9b5d2eb41a1d56.tar.xz mullvadvpn-d0dcf31199cc3efa23645312fb9b5d2eb41a1d56.zip | |
SelectLocation in reactxp
Diffstat (limited to 'test/components')
| -rw-r--r-- | test/components/SelectLocation.spec.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js index 59a8dc9770..4e2265c6dd 100644 --- a/test/components/SelectLocation.spec.js +++ b/test/components/SelectLocation.spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as React from 'react'; -import ReactTestUtils, { Simulate } from 'react-dom/test-utils'; +import { shallow } from 'enzyme'; import SelectLocation from '../../app/components/SelectLocation'; import type { SettingsReduxState } from '../../app/redux/settings/reducers'; @@ -48,7 +48,7 @@ describe('components/SelectLocation', () => { }; const render = (props: SelectLocationProps) => { - return ReactTestUtils.renderIntoDocument( + return shallow( <SelectLocation { ...props } /> ); }; @@ -57,11 +57,8 @@ describe('components/SelectLocation', () => { const props = makeProps(state, { onClose: () => done() }); - const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(render(props), 'select-location__close'); - // See: https://github.com/facebook/flow/pull/5841 - if(domNode) { - Simulate.click(domNode); - } + const node = getComponent(render(props), 'close'); + click(node); }); it('should call select callback for country', (done) => { @@ -77,9 +74,9 @@ describe('components/SelectLocation', () => { } } }); - const elements = ReactTestUtils.scryRenderedDOMComponentsWithClass(render(props), 'select-location__cell'); + const elements = getComponent(render(props), 'country'); expect(elements).to.have.length(1); - Simulate.click(elements[0]); + click(elements.at(0)); }); it('should call select callback for city', (done) => { @@ -95,9 +92,17 @@ describe('components/SelectLocation', () => { } } }); - const elements = ReactTestUtils.scryRenderedDOMComponentsWithClass(render(props), 'select-location__sub-cell'); + const elements = getComponent(render(props), 'city'); expect(elements).to.have.length(2); - Simulate.click(elements[0]); + click(elements.at(0)); }); }); + +function getComponent(container, testName) { + return container.findWhere( n => n.prop('testName') === testName); +} + +function click(component) { + component.prop('onPress')(); +} |
