markdown.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
  2. import 'mocha'
  3. import { mdToOneLinePlainText } from '@server/helpers/markdown'
  4. import { expect } from 'chai'
  5. describe('Markdown helpers', function () {
  6. describe('Plain text', function () {
  7. it('Should convert a list to plain text', function () {
  8. const result = mdToOneLinePlainText(`* list 1
  9. * list 2
  10. * list 3`)
  11. expect(result).to.equal('list 1, list 2, list 3')
  12. })
  13. it('Should convert a list with indentation to plain text', function () {
  14. const result = mdToOneLinePlainText(`Hello:
  15. * list 1
  16. * list 2
  17. * list 3`)
  18. expect(result).to.equal('Hello: list 1, list 2, list 3')
  19. })
  20. it('Should convert HTML to plain text', function () {
  21. const result = mdToOneLinePlainText(`**Hello** <strong>coucou</strong>`)
  22. expect(result).to.equal('Hello coucou')
  23. })
  24. it('Should convert tags to plain text', function () {
  25. const result = mdToOneLinePlainText(`#déconversion\n#newage\n#histoire`)
  26. expect(result).to.equal('#déconversion #newage #histoire')
  27. })
  28. })
  29. })