]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - test/unit/helpers.js
rollup v2->v3, convert -require- to ESM style -import-
[nominatim-ui.git] / test / unit / helpers.js
index 95700596a0c9e8092280e7f2d1e437c4cb7c45d4..cea1512e23f5ad68459fb63d3f5a331982d4fba6 100644 (file)
@@ -1,36 +1,36 @@
-const assert = require('assert');
-const helpers = require('../../src/lib/helpers');
+import assert from 'assert';
+import { formatLabel, wikipediaLink } from '../../src/lib/helpers.js';
 
 describe('Helpers', function () {
 
   it('.formatLabel', function () {
     // not enough data
-    assert.equal(helpers.formatLabel({}), '');
+    assert.equal(formatLabel({}), '');
 
     // if label set, that becomes the label
-    assert.equal(helpers.formatLabel({ label: 'A Label' }), 'A Label');
+    assert.equal(formatLabel({ label: 'A Label' }), 'A Label');
 
     // type, but nicely formatted
-    assert.equal(helpers.formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
+    assert.equal(formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
 
     // type=yes, so we use the category
-    assert.equal(helpers.formatLabel({ category: 'building', type: 'yes' }), 'Building');
+    assert.equal(formatLabel({ category: 'building', type: 'yes' }), 'Building');
   });
 
   it('.wikipediaLink', function () {
     assert.equal(
-      helpers.wikipediaLink({}),
+      wikipediaLink({}),
       ''
     );
 
     assert.equal(
-      helpers.wikipediaLink({ calculated_wikipedia: 'de:Brandenburg Gate' }),
+      wikipediaLink({ calculated_wikipedia: 'de:Brandenburg Gate' }),
       '<a href="https://de.wikipedia.org/wiki/Brandenburg Gate" target="_blank">de:Brandenburg Gate</a>'
     );
 
     // title includes HTML
     assert.equal(
-      helpers.wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
+      wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
       '<a href="https://en.wikipedia.org/wiki/Slug &amp; Lattuce" target="_blank">en:Slug &amp; Lattuce</a>'
     );
   });