PeerTube/server/tests/helpers/comment-model.ts

28 lines
867 B
TypeScript
Raw Normal View History

2020-01-31 16:56:52 +01:00
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
2021-07-16 14:27:30 +02:00
import * as chai from 'chai'
import { VideoCommentModel } from '../../models/video/video-comment'
const expect = chai.expect
class CommentMock {
text: string
extractMentions = VideoCommentModel.prototype.extractMentions
2019-02-14 11:58:08 +01:00
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'
2020-01-31 16:56:52 +01:00
const result = comment.extractMentions().sort((a, b) => a.localeCompare(b))
expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ])
})
})