-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
IgnoreWordsDictionary.test.ts
92 lines (84 loc) · 4.41 KB
/
IgnoreWordsDictionary.test.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { createIgnoreWordsDictionary } from './IgnoreWordsDictionary';
// const oc = expect.objectContaining;
// cspell:ignore êphone îphone geschäft
describe('IgnoreWordsDictionary', () => {
const dictWords = [' English', 'grumpy', 'Avocado', 'avocados', 'Café', ' êphone', 'îphone', 'geschäft'];
const dict = createIgnoreWordsDictionary(dictWords, 'ignore words', 'test');
test.each`
word | expected
${''} | ${false}
${'avocado'} | ${true}
${'Avocado'} | ${true}
${'english'} | ${true}
${'English'} | ${true}
${'grumpy'} | ${true}
${'Grumpy'} | ${true}
`('has of "$word"', async ({ word, expected }) => {
expect(dict.has(word)).toEqual(expected);
});
test.each`
word | options | expected
${'avocado'} | ${undefined} | ${{ found: 'avocado', forbidden: false, noSuggest: true }}
${'Avocado'} | ${undefined} | ${{ found: 'Avocado', forbidden: false, noSuggest: true }}
${'Avocado'} | ${{ ignoreCase: true }} | ${{ found: 'Avocado', forbidden: false, noSuggest: true }}
${''} | ${undefined} | ${undefined}
${'English'} | ${{ ignoreCase: true }} | ${{ found: 'English', forbidden: false, noSuggest: true }}
${'English'} | ${{ ignoreCase: false }} | ${{ found: 'English', forbidden: false, noSuggest: true }}
${'english'} | ${{ ignoreCase: true }} | ${{ found: 'english', forbidden: false, noSuggest: true }}
${'english'} | ${{ ignoreCase: false }} | ${undefined}
${'îphone'.normalize('NFC')} | ${undefined} | ${{ found: 'îphone'.normalize('NFC'), forbidden: false, noSuggest: true }}
${'îphone'.normalize('NFD')} | ${undefined} | ${{ found: 'îphone'.normalize('NFC'), forbidden: false, noSuggest: true }}
${'iphone'} | ${undefined} | ${{ found: 'iphone', forbidden: false, noSuggest: true }}
`('find "$word" $options', async ({ word, options, expected }) => {
expect(dict.find(word, options)).toEqual(expected);
});
test.each`
word | ignoreCase | expected
${''} | ${undefined} | ${false}
${'avocado'} | ${false} | ${false}
${'avocado'} | ${undefined} | ${true}
${'avocado'} | ${true} | ${true}
${'Avocado'} | ${undefined} | ${true}
${'avocadoS'} | ${undefined} | ${true}
${'AvocadoS'} | ${undefined} | ${true}
${'Café'} | ${false} | ${true}
${'cafe'} | ${false} | ${false}
${'cafe'} | ${true} | ${true}
${'îphone'.normalize('NFC')} | ${true} | ${true}
${'îphone'.normalize('NFD')} | ${true} | ${true}
${'english'} | ${undefined} | ${true}
${'English'} | ${undefined} | ${true}
${'grumpy'} | ${undefined} | ${true}
${'Grumpy'} | ${undefined} | ${true}
`('isNoSuggestWord of "$word" ignoreCase: $ignoreCase', async ({ word, ignoreCase, expected }) => {
expect(dict.isNoSuggestWord(word, { ignoreCase })).toEqual(expected);
});
test.each`
word | expected
${'avocado'} | ${false}
${'Avocado'} | ${false}
${''} | ${false}
${'English'} | ${false}
${'english'} | ${false}
${'avocadoS'} | ${false}
${'AvocadoS'} | ${false}
${'grumpy'} | ${false}
${'Grumpy'} | ${false}
`('isForbidden of "$word"', async ({ word, expected }) => {
expect(dict.isForbidden(word)).toEqual(expected);
});
test.each`
word | expected
${'avocado'} | ${[]}
${'Avocado'} | ${[]}
${''} | ${[]}
${'English'} | ${[]}
${'english'} | ${[]}
${'avocadoS'} | ${[]}
${'AvocadoS'} | ${[]}
${'grumpy'} | ${[]}
${'Grumpy'} | ${[]}
`('suggest of "$word"', async ({ word, expected }) => {
expect(dict.suggest(word)).toEqual(expected);
});
});