-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
39 lines (34 loc) · 931 Bytes
/
test.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
30
31
32
33
34
35
36
37
38
import { test } from 'node:test';
import assert from 'node:assert';
import FuzzySet from './index.js';
const countries = [
'Afghanistan',
'Albania',
'Algeria',
'Andorra',
'Angola',
'Antigua and Barbuda',
'Argentine',
'Armenia',
'Australia',
'Austria',
'Azerbaijan',
]
test('countries', () => {
const set = new FuzzySet(countries);
const ranks = set.match('an');
const [winner] = ranks.map(([i, score]) => [countries[i], score])
assert.equal(winner[0], 'Angola');
})
test('missing letter', () => {
const set = new FuzzySet(countries);
const ranks = set.match('andora');
const [winner] = ranks.map(([i, score]) => [countries[i], score])
assert.equal(winner[0], 'Andorra');
})
test('missing vowels', () => {
const set = new FuzzySet(countries);
const ranks = set.match('andr');
const [winner] = ranks.map(([i, score]) => [countries[i], score])
assert.equal(winner[0], 'Andorra');
})