fuzzy-tools
Version:
Functions for fuzzy matching and items filtering
31 lines (29 loc) • 956 B
JavaScript
import { matchString } from '../../src';
const testData = [
['fuXXX???', ['fuz--', '--fuz', 'f--uz', 'fu--z', '-fuz-', 'f-u-z', 'xxfxxx-xxxuxxx-xxzxxxzzzz fu zzz']],
[
'!vu80u581q',
[
'vwl2 bj 0wt1i rm5u-2io 48kl4- 7 _4 mte9u0i 7v ur4yowf-jt5w x6hw6gt 6ihvmv 084ng1ji w99ikng_59 u7j63q ',
'vu80u581q',
'----v----u-80u58--1q---',
]
],
['', ['fuz--']],
['f', [{}, [], new Date(), 123, 19.22, null, undefined]],
[null, ['fuz--']],
[{}, ['fuz--']],
[[], ['fuz--']],
[new Date(), ['fuz--']],
['zzz', ['', null, 123, {}, [], new Date(), undefined, 11.3, NaN]],
];
describe('matchString(...) = true', () => {
describe.each(testData)('%#. %j', (what, whereList) => {
test.each(whereList)('%#. %s', (where) => {
expect(!!matchString(what, where))
.toBe(false);
expect(!!matchString(what, where, { withScore: false }))
.toBe(false);
});
});
});