2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2019-01-04 01:56:20 -06:00
|
|
|
|
2022-08-17 08:44:32 -05:00
|
|
|
import { expect } from 'chai'
|
2019-01-04 01:56:20 -06:00
|
|
|
import { VideoCommentModel } from '../../models/video/video-comment'
|
|
|
|
|
|
|
|
class CommentMock {
|
|
|
|
text: string
|
|
|
|
|
|
|
|
extractMentions = VideoCommentModel.prototype.extractMentions
|
2019-02-14 04:58:08 -06:00
|
|
|
|
|
|
|
isOwned = () => true
|
2019-01-04 01:56:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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 09:56:52 -06:00
|
|
|
const result = comment.extractMentions().sort((a, b) => a.localeCompare(b))
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ])
|
|
|
|
})
|
|
|
|
})
|