philomena/assets/js/utils/__tests__/suggestion-model.spec.ts

38 lines
790 B
TypeScript
Raw Normal View History

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",
]
`);
});
});