mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
23 lines
723 B
TypeScript
23 lines
723 B
TypeScript
// eslint-disable-next-line import-x/no-unresolved -- bun
|
|
import { describe, expect, it } from 'bun:test';
|
|
import createKeywordFilter from './aho-corasick';
|
|
|
|
describe('AhoCorasick', () => {
|
|
it('basic', () => {
|
|
let kwfilter = createKeywordFilter(['ap', 'an']);
|
|
expect(kwfilter('bananan')).toBeTrue();
|
|
expect(kwfilter('apple')).toBeTrue();
|
|
expect(kwfilter('melon')).toBeFalse();
|
|
|
|
console.log(kwfilter);
|
|
|
|
kwfilter = createKeywordFilter(['cdn', 'sukka']);
|
|
expect(kwfilter('bananan')).toBeFalse();
|
|
expect(kwfilter('apple')).toBeFalse();
|
|
expect(kwfilter('melon')).toBeFalse();
|
|
|
|
console.log(kwfilter);
|
|
console.log(createKeywordFilter(['skk.moe', 'anotherskk', 'skk.com']));
|
|
});
|
|
});
|