diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2017-12-12 18:37:16 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2017-12-19 10:32:24 +0100 |
| commit | 035fdd96ba2a1a10885e4d69f2ae890272702f32 (patch) | |
| tree | d8b465aa3e86490f83ea28f03c95600ed329b114 /test/components | |
| parent | 4353ec7bd52585c67324c0fabcd76473d4150600 (diff) | |
| download | mullvadvpn-035fdd96ba2a1a10885e4d69f2ae890272702f32.tar.xz mullvadvpn-035fdd96ba2a1a10885e4d69f2ae890272702f32.zip | |
Render two level location list
Diffstat (limited to 'test/components')
| -rw-r--r-- | test/components/SelectLocation.spec.js | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js index 099594ca66..3266fe7aa9 100644 --- a/test/components/SelectLocation.spec.js +++ b/test/components/SelectLocation.spec.js @@ -18,7 +18,16 @@ describe('components/SelectLocation', () => { } }, relayLocations: { - countries: [], + countries: [{ + name: 'Sweden', + code: 'se', + cities: [{ + name: 'Malmö', + code: 'mma', + position: [0, 0], + has_active_relays: true, + }], + }], }, }; @@ -45,13 +54,37 @@ describe('components/SelectLocation', () => { Simulate.click(domNode); }); - it('should call select callback', (done) => { + it('should call select callback for country', (done) => { const props = makeProps(state, { - onSelect: (_server) => done() + onSelect: (location) => { + done(new Error('Fix me! ' + JSON.stringify(location))); + } }); const elements = ReactTestUtils.scryRenderedDOMComponentsWithClass(render(props), 'select-location__cell'); - expect(elements).to.have.length.greaterThan(1); - Simulate.click(elements[1]); + expect(elements).to.have.length(1); + Simulate.click(elements[0]); + }); + + it('should call select callback for city', (done) => { + const testState = { + ...state, + relaySettings: { + normal: { + // should auto-expand Sweden + location: { city: ['se', 'mma'] }, + protocol: 'any', + port: 'any', + } + } + }; + const props = makeProps(testState, { + onSelect: (location) => { + done(new Error('Fix me! ' + JSON.stringify(location))); + } + }); + const elements = ReactTestUtils.scryRenderedDOMComponentsWithClass(render(props), 'select-location__sub-cell'); + expect(elements).to.have.length(1); + Simulate.click(elements[0]); }); }); |
