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]);
+ assert.deepStrictEqual(identifyLinkInQuery('R-123'), ['R', -123]);
+ });
+
it('.formatLabel', function () {
// not enough data
assert.equal(formatLabel({}), '');