diff options
Diffstat (limited to 'packages/tests/src/server-helpers/markdown.ts')
-rw-r--r-- | packages/tests/src/server-helpers/markdown.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/tests/src/server-helpers/markdown.ts b/packages/tests/src/server-helpers/markdown.ts new file mode 100644 index 000000000..96e3c34dc --- /dev/null +++ b/packages/tests/src/server-helpers/markdown.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { mdToOneLinePlainText } from '@peertube/peertube-server/server/helpers/markdown.js' | ||
4 | import { expect } from 'chai' | ||
5 | |||
6 | describe('Markdown helpers', function () { | ||
7 | |||
8 | describe('Plain text', function () { | ||
9 | |||
10 | it('Should convert a list to plain text', function () { | ||
11 | const result = mdToOneLinePlainText(`* list 1 | ||
12 | * list 2 | ||
13 | * list 3`) | ||
14 | |||
15 | expect(result).to.equal('list 1, list 2, list 3') | ||
16 | }) | ||
17 | |||
18 | it('Should convert a list with indentation to plain text', function () { | ||
19 | const result = mdToOneLinePlainText(`Hello: | ||
20 | * list 1 | ||
21 | * list 2 | ||
22 | * list 3`) | ||
23 | |||
24 | expect(result).to.equal('Hello: list 1, list 2, list 3') | ||
25 | }) | ||
26 | |||
27 | it('Should convert HTML to plain text', function () { | ||
28 | const result = mdToOneLinePlainText(`**Hello** <strong>coucou</strong>`) | ||
29 | |||
30 | expect(result).to.equal('Hello coucou') | ||
31 | }) | ||
32 | |||
33 | it('Should convert tags to plain text', function () { | ||
34 | const result = mdToOneLinePlainText(`#déconversion\n#newage\n#histoire`) | ||
35 | |||
36 | expect(result).to.equal('#déconversion #newage #histoire') | ||
37 | }) | ||
38 | }) | ||
39 | }) | ||