-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
29 lines (25 loc) · 902 Bytes
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict'
const expect = require('code').expect
const Lab = require('lab')
const lab = exports.lab = Lab.script()
const LevenshteinMap = require('./levenshtein-map')
lab.test ('Exact match returns the expected object', (done) => {
let levenshtein = new LevenshteinMap()
levenshtein.put('test', 'test')
expect(levenshtein.get('test')).to.equal('test')
done()
})
lab.test('Default returns a value even if it is not close in distance', (done) => {
let levenshtein = new LevenshteinMap()
levenshtein.put('test', 'test')
expect(levenshtein.get('unexpected')).to.equal('test')
done()
})
lab.test('Returns the closest to the key', (done) => {
let levenshtein = new LevenshteinMap()
levenshtein.put('test', 'test')
levenshtein.put('unicorn', 'weeeeee')
expect(levenshtein.get('unexpected')).to.equal('weeeeee')
expect(levenshtein.get('testarama')).to.equal('test')
done()
})