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