|
1 | 1 | const Lab = require('@hapi/lab')
|
2 | 2 | const { expect } = require('@hapi/code')
|
3 |
| -const { experiment, test } = exports.lab = Lab.script() |
4 |
| -const { formatName } = require('../../../server/services/lib/bing-utils') |
| 3 | +const { experiment, it } = exports.lab = Lab.script() |
| 4 | +const { formatName, slugify } = require('../../../server/services/lib/bing-utils') |
5 | 5 |
|
6 | 6 | experiment('bing utils', () => {
|
7 | 7 | experiment('formatName', () => {
|
8 |
| - test('Repeating parts are removed', async () => { |
| 8 | + it('Repeating parts are removed', async () => { |
9 | 9 | expect(formatName('Middlesbrough, Middlesbrough')).to.equal('Middlesbrough')
|
10 | 10 | })
|
11 |
| - test('Similar parts are not removed', async () => { |
| 11 | + it('Similar parts are not removed', async () => { |
12 | 12 | expect(formatName('Durham, County Durham')).to.equal('Durham, County Durham')
|
13 | 13 | })
|
14 |
| - test('City qualifier "City Of" is removed', async () => { |
| 14 | + it('City qualifier "City Of" is removed', async () => { |
15 | 15 | expect(formatName('Bristol, City Of Bristol')).to.equal('Bristol')
|
16 | 16 | })
|
17 |
| - test('City qualifier "City of" is removed (ie case insensitive)', async () => { |
| 17 | + it('City qualifier "City of" is removed (ie case insensitive)', async () => { |
18 | 18 | expect(formatName('Bristol, City of Bristol')).to.equal('Bristol')
|
19 | 19 | })
|
20 |
| - test('City qualifier "Greater" is removed', async () => { |
| 20 | + it('City qualifier "Greater" is removed', async () => { |
21 | 21 | expect(formatName('London, Greater London')).to.equal('London')
|
22 | 22 | })
|
23 |
| - test('City qualifier removed from neighbourhood', async () => { |
| 23 | + it('City qualifier removed from neighbourhood', async () => { |
24 | 24 | expect(formatName('Camberwell, London, Greater London')).to.equal('Camberwell, London')
|
25 | 25 | })
|
26 | 26 | experiment('Error handling', () => {
|
27 |
| - test('Fails gracefully with undefined name', async () => { |
| 27 | + it('Fails gracefully with undefined name', async () => { |
28 | 28 | expect(formatName()).to.equal('')
|
29 | 29 | })
|
30 | 30 | })
|
31 | 31 | })
|
| 32 | + experiment('slugify', () => { |
| 33 | + it('Simple name is slugified', async () => { |
| 34 | + expect(slugify('Leeds, West Yorkshire')).to.equal('leeds-west-yorkshire') |
| 35 | + }) |
| 36 | + it('Non-alphanumerics (!) are preserved', async () => { |
| 37 | + expect(slugify('Westward Ho!, Bideford, Devon')).to.equal('westward-ho!-bideford-devon') |
| 38 | + }) |
| 39 | + it('Non-alphanumerics (\') are preserved', async () => { |
| 40 | + expect(slugify('Bishop\'s Stortford')).to.equal('bishop\'s-stortford') |
| 41 | + }) |
| 42 | + }) |
32 | 43 | })
|
0 commit comments