mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-20 02:37:14 +01:00
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import { prefixMatchParts } from '../suggestions-model.ts';
|
|
|
|
describe('prefixMatchParts', () => {
|
|
it('separates the prefix from the plain tag', () => {
|
|
expect(prefixMatchParts('foobar', 'foo')).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"matched": "foo",
|
|
},
|
|
"bar",
|
|
]
|
|
`);
|
|
});
|
|
|
|
it('separates the prefix from the namespaced tag', () => {
|
|
expect(prefixMatchParts('bruh:bar', 'bru')).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"matched": "bru",
|
|
},
|
|
"h:bar",
|
|
]
|
|
`);
|
|
});
|
|
|
|
it('separates the prefix after the namespace', () => {
|
|
expect(prefixMatchParts('foo:bazz', 'baz')).toMatchInlineSnapshot(`
|
|
[
|
|
"foo:",
|
|
{
|
|
"matched": "baz",
|
|
},
|
|
"z",
|
|
]
|
|
`);
|
|
});
|
|
|
|
it(`should ignore case when matching`, () => {
|
|
expect(prefixMatchParts('FOObar', 'foo')).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"matched": "FOO",
|
|
},
|
|
"bar",
|
|
]
|
|
`);
|
|
});
|
|
|
|
it(`should skip empty parts`, () => {
|
|
expect(prefixMatchParts('foo', 'foo')).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"matched": "foo",
|
|
},
|
|
]
|
|
`);
|
|
expect(prefixMatchParts('foo', 'bar')).toMatchInlineSnapshot(`
|
|
[
|
|
"foo",
|
|
]
|
|
`);
|
|
});
|
|
});
|