aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/helpers/comment-model.ts
blob: e39cae442ec8569346e38038c4a61360cdf5fe74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import { expect } from 'chai'
import { VideoCommentModel } from '../../models/video/video-comment'

class CommentMock {
  text: string

  extractMentions = VideoCommentModel.prototype.extractMentions

  isOwned = () => true
}

describe('Comment model', function () {
  it('Should correctly extract mentions', async function () {
    const comment = new CommentMock()

    comment.text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' +
      'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end'
    const result = comment.extractMentions().sort((a, b) => a.localeCompare(b))

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