X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/b2d1e2a271b3f2157987908bb284be14732a747b..7ed97d6aceab15f29088f45aa6fbf1eda551173d:/test/unit/helpers.js diff --git a/test/unit/helpers.js b/test/unit/helpers.js index cea1512..ed57c03 100644 --- a/test/unit/helpers.js +++ b/test/unit/helpers.js @@ -1,8 +1,17 @@ import assert from 'assert'; -import { formatLabel, wikipediaLink } from '../../src/lib/helpers.js'; +import { identifyLinkInQuery, formatLabel, wikipediaLink } from '../../src/lib/helpers.js'; describe('Helpers', function () { + it('.identifyLinkInQuery', function () { + assert.equal(identifyLinkInQuery(''), undefined); + assert.equal(identifyLinkInQuery('http://example.com'), undefined); + + assert.deepStrictEqual(identifyLinkInQuery('https://www.openstreetmap.org/relation/1234#map=11/41.2388/-8.3867'), ['R', 1234]); + assert.deepStrictEqual(identifyLinkInQuery('n1234'), ['N', 1234]); + assert.deepStrictEqual(identifyLinkInQuery('W1234'), ['W', 1234]); + }); + it('.formatLabel', function () { // not enough data assert.equal(formatLabel({}), '');