diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-04 10:31:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-02-04 10:38:32 +0100 |
commit | c68e2b2d223c57836e04e18105255cf0e10ae75b (patch) | |
tree | a40348363efc90464ff44306435d45079b0b7fca /server/tests/helpers | |
parent | 457c83486ed2037a8cf0e55b06b1ae9370ed4d93 (diff) | |
download | PeerTube-c68e2b2d223c57836e04e18105255cf0e10ae75b.tar.gz PeerTube-c68e2b2d223c57836e04e18105255cf0e10ae75b.tar.zst PeerTube-c68e2b2d223c57836e04e18105255cf0e10ae75b.zip |
Fix plaintext markdown converter
Diffstat (limited to 'server/tests/helpers')
-rw-r--r-- | server/tests/helpers/index.ts | 1 | ||||
-rw-r--r-- | server/tests/helpers/markdown.ts | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/server/tests/helpers/index.ts b/server/tests/helpers/index.ts index 66db93c99..91d11e25d 100644 --- a/server/tests/helpers/index.ts +++ b/server/tests/helpers/index.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import './image' | 1 | import './image' |
2 | import './core-utils' | 2 | import './core-utils' |
3 | import './comment-model' | 3 | import './comment-model' |
4 | import './markdown' | ||
4 | import './request' | 5 | import './request' |
diff --git a/server/tests/helpers/markdown.ts b/server/tests/helpers/markdown.ts new file mode 100644 index 000000000..0488a1a05 --- /dev/null +++ b/server/tests/helpers/markdown.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import { mdToOneLinePlainText } from '@server/helpers/markdown' | ||
5 | import { expect } from 'chai' | ||
6 | |||
7 | describe('Markdown helpers', function () { | ||
8 | |||
9 | describe('Plain text', function () { | ||
10 | |||
11 | it('Should convert a list to plain text', function () { | ||
12 | const result = mdToOneLinePlainText(`* list 1 | ||
13 | * list 2 | ||
14 | * list 3`) | ||
15 | |||
16 | expect(result).to.equal('list 1, list 2, list 3') | ||
17 | }) | ||
18 | |||
19 | it('Should convert a list with indentation to plain text', function () { | ||
20 | const result = mdToOneLinePlainText(`Hello: | ||
21 | * list 1 | ||
22 | * list 2 | ||
23 | * list 3`) | ||
24 | |||
25 | expect(result).to.equal('Hello: list 1, list 2, list 3') | ||
26 | }) | ||
27 | |||
28 | it('Should convert HTML to plain text', function () { | ||
29 | const result = mdToOneLinePlainText(`**Hello** <strong>coucou</strong>`) | ||
30 | |||
31 | expect(result).to.equal('Hello coucou') | ||
32 | }) | ||
33 | }) | ||
34 | }) | ||