diff options
Diffstat (limited to 'packages/tests/src/server-helpers/mentions.ts')
-rw-r--r-- | packages/tests/src/server-helpers/mentions.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/tests/src/server-helpers/mentions.ts b/packages/tests/src/server-helpers/mentions.ts new file mode 100644 index 000000000..153931d60 --- /dev/null +++ b/packages/tests/src/server-helpers/mentions.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { extractMentions } from '@peertube/peertube-server/server/helpers/mentions.js' | ||
5 | |||
6 | describe('Comment model', function () { | ||
7 | it('Should correctly extract mentions', async function () { | ||
8 | const text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' + | ||
9 | 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end' | ||
10 | |||
11 | const isOwned = true | ||
12 | |||
13 | const result = extractMentions(text, isOwned).sort((a, b) => a.localeCompare(b)) | ||
14 | |||
15 | expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ]) | ||
16 | }) | ||
17 | }) | ||