]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/helpers/comment-model.ts
We don't need to import mocha
[github/Chocobozzz/PeerTube.git] / server / tests / helpers / comment-model.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import * as chai from 'chai'
4 import { VideoCommentModel } from '../../models/video/video-comment'
5
6 const expect = chai.expect
7
8 class CommentMock {
9 text: string
10
11 extractMentions = VideoCommentModel.prototype.extractMentions
12
13 isOwned = () => true
14 }
15
16 describe('Comment model', function () {
17 it('Should correctly extract mentions', async function () {
18 const comment = new CommentMock()
19
20 comment.text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' +
21 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end'
22 const result = comment.extractMentions().sort((a, b) => a.localeCompare(b))
23
24 expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ])
25 })
26 })