1 const assert = require('assert');
2 const helpers = require('../../src/lib/helpers');
4 describe('Helpers', function () {
6 it('.formatLabel', function () {
8 assert.equal(helpers.formatLabel({}), '');
10 // if label set, that becomes the label
11 assert.equal(helpers.formatLabel({ label: 'A Label' }), 'A Label');
13 // type, but nicely formatted
14 assert.equal(helpers.formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
16 // type=yes, so we use the category
17 assert.equal(helpers.formatLabel({ category: 'building', type: 'yes' }), 'Building');
20 it('.wikipediaLink', function () {
22 helpers.wikipediaLink({}),
27 helpers.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 helpers.wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
34 '<a href="https://en.wikipedia.org/wiki/Slug & Lattuce" target="_blank">en:Slug & Lattuce</a>'