2
1

comment-model.ts 786 B

123456789101112131415161718192021222324252627
  1. /* tslint:disable:no-unused-expression */
  2. import * as chai from 'chai'
  3. import 'mocha'
  4. import { VideoCommentModel } from '../../models/video/video-comment'
  5. const expect = chai.expect
  6. class CommentMock {
  7. text: string
  8. extractMentions = VideoCommentModel.prototype.extractMentions
  9. isOwned = () => true
  10. }
  11. describe('Comment model', function () {
  12. it('Should correctly extract mentions', async function () {
  13. const comment = new CommentMock()
  14. comment.text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' +
  15. 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end'
  16. const result = comment.extractMentions().sort()
  17. expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ])
  18. })
  19. })