/
fuzzy-matcher.test.ts
34 lines (25 loc) · 1.11 KB
/
fuzzy-matcher.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
/******************************************************************************
* Copyright 2023 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { describe, expect, test } from 'vitest';
import { DefaultFuzzyMatcher } from '../../src/lsp/fuzzy-matcher.js';
const matcher = new DefaultFuzzyMatcher();
describe('Fuzzy Matcher', () => {
test('Matches full string', () => {
expect(matcher.match('Hello', 'Hello')).toBeTruthy();
});
test('Matches first few characters', () => {
expect(matcher.match('He', 'Hello')).toBeTruthy();
});
test('Matches first few characters - negative', () => {
expect(matcher.match('ell', 'Hello')).toBeFalsy();
});
test('Matches omitted characters', () => {
expect(matcher.match('Ho', 'Hello')).toBeTruthy();
});
test('Matches omitted characters - negative', () => {
expect(matcher.match('Hi', 'Hello')).toBeFalsy();
});
});