1 import assert from 'assert';
2 import { formatLabel, wikipediaLink } from '../../src/lib/helpers.js';
4 describe('Helpers', function () {
6 it('.formatLabel', function () {
8 assert.equal(formatLabel({}), '');
10 // if label set, that becomes the label
11 assert.equal(formatLabel({ label: 'A Label' }), 'A Label');
13 // type, but nicely formatted
14 assert.equal(formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
16 // type=yes, so we use the category
17 assert.equal(formatLabel({ category: 'building', type: 'yes' }), 'Building');
20 it('.wikipediaLink', function () {
27 wikipediaLink({ calculated_wikipedia: 'de:Brandenburg Gate' }),
28 '<a href="https://de.wikipedia.org/wiki/Brandenburg Gate" target="_blank">de:Brandenburg Gate</a>'
31 // title includes HTML
33 wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
34 '<a href="https://en.wikipedia.org/wiki/Slug & Lattuce" target="_blank">en:Slug & Lattuce</a>'