aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/src/server-helpers/markdown.ts
blob: 96e3c34dc2cbaa350b178ce1b189ba94ff8a5747 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import { mdToOneLinePlainText } from '@peertube/peertube-server/server/helpers/markdown.js'
import { expect } from 'chai'

describe('Markdown helpers', function () {

  describe('Plain text', function () {

    it('Should convert a list to plain text', function () {
      const result = mdToOneLinePlainText(`* list 1
* list 2
* list 3`)

      expect(result).to.equal('list 1, list 2, list 3')
    })

    it('Should convert a list with indentation to plain text', function () {
      const result = mdToOneLinePlainText(`Hello:
  * list 1
  * list 2
  * list 3`)

      expect(result).to.equal('Hello: list 1, list 2, list 3')
    })

    it('Should convert HTML to plain text', function () {
      const result = mdToOneLinePlainText(`**Hello** <strong>coucou</strong>`)

      expect(result).to.equal('Hello coucou')
    })

    it('Should convert tags to plain text', function () {
      const result = mdToOneLinePlainText(`#déconversion\n#newage\n#histoire`)

      expect(result).to.equal('#déconversion #newage #histoire')
    })
  })
})