From 23d68e84c00ba741a29e4e088ef12aa7b23e045c Mon Sep 17 00:00:00 2001 From: mtmail Date: Mon, 19 Apr 2021 16:22:41 +0200 Subject: [PATCH] reverse page: dont switch empty coordinates (#130) --- src/components/SearchSectionReverse.svelte | 2 ++ test/reverse.js | 36 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/reverse.js diff --git a/src/components/SearchSectionReverse.svelte b/src/components/SearchSectionReverse.svelte index aca422d..1861902 100644 --- a/src/components/SearchSectionReverse.svelte +++ b/src/components/SearchSectionReverse.svelte @@ -9,6 +9,8 @@ export let zoom = ''; function gotoCoordinates(newlat, newlon, newzoom) { + if (newlat === null || newlon === null) return; + let params = new URLSearchParams(); params.set('lat', newlat); params.set('lon', newlon); diff --git a/test/reverse.js b/test/reverse.js new file mode 100644 index 0000000..8e02b23 --- /dev/null +++ b/test/reverse.js @@ -0,0 +1,36 @@ +const assert = require('assert'); + +describe('Reverse Page', function () { + let page; + + describe('No search', function () { + before(async function () { + page = await browser.newPage(); + await page.goto('http://localhost:9999/reverse.html'); + }); + + after(async function () { + await page.close(); + }); + + it('should allow switching coordinates', async function () { + let lat_handle = await page.$('input[name=lat]'); + let lon_handle = await page.$('input[name=lon]'); + + assert.equal(await lat_handle.evaluate(node => node.value), ''); + assert.equal(await lon_handle.evaluate(node => node.value), ''); + + await page.click('#switch-coords'); + // no change + assert.equal(await lat_handle.evaluate(node => node.value), ''); + assert.equal(await lon_handle.evaluate(node => node.value), ''); + + await page.type('input[name=lat]', '5'); + await page.type('input[name=lon]', '10'); + await page.click('#switch-coords'); + // switched + assert.equal(await lat_handle.evaluate(node => node.value), 10); + assert.equal(await lon_handle.evaluate(node => node.value), 5); + }); + }); +}); -- 2.39.5