deno.land / x / fuse@v6.4.1 / test / extended-search.test.js

extended-search.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
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
const Fuse = require('../dist/fuse')
describe('Searching using extended search', () => { const list = [ { text: 'hello word' }, { text: 'how are you' }, { text: 'indeed fine hello foo' }, { text: 'I am fine' }, { text: 'smithee' }, { text: 'smith' } ]
const options = { useExtendedSearch: true, includeMatches: true, includeScore: true, threshold: 0.5, minMatchCharLength: 4, keys: ['text'] } const fuse = new Fuse(list, options)
test('Search: exact-match', () => { let result = fuse.search('=smith') expect(result).toMatchSnapshot() })
test('Search: include-match', () => { let result = fuse.search("'hello") expect(result).toMatchSnapshot() })
test('Search: prefix-exact-match', () => { let result = fuse.search('^hello') expect(result).toMatchSnapshot() })
test('Search: suffix-exact-match', () => { let result = fuse.search('fine$') expect(result).toMatchSnapshot() })
test('Search: inverse-exact-match', () => { let result = fuse.search('!indeed') expect(result).toMatchSnapshot() })
test('Search: inverse-prefix-exact-match', () => { let result = fuse.search('!^hello') expect(result).toMatchSnapshot() })
test('Search: inverse-suffix-exact-match', () => { let result = fuse.search('!foo$') expect(result).toMatchSnapshot() })
test('Search: all', () => { let result = fuse.search('!foo$ !^how') expect(result).toMatchSnapshot() })
test('Search: single literal match', () => { let result = fuse.search('\'"indeed fine"') expect(result).toMatchSnapshot() })
test('Search: literal match with regular match', () => { let result = fuse.search('\'"indeed fine" foo$ | \'are') expect(result).toMatchSnapshot() })
test('Search: literal match with fuzzy match', () => { let result = fuse.search('\'"indeed fine" foo$ | helol') expect(result).toMatchSnapshot() })})
fuse

Version Info

Tagged at
3 years ago