aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/src/server-helpers/mentions.ts
blob: 153931d60bbe5f2ac158a97f2bc080c50f6beade (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import { expect } from 'chai'
import { extractMentions } from '@peertube/peertube-server/server/helpers/mentions.js'

describe('Comment model', function () {
  it('Should correctly extract mentions', async function () {
    const text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' +
      'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end'

    const isOwned = true

    const result = extractMentions(text, isOwned).sort((a, b) => a.localeCompare(b))

    expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ])
  })
})