-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathmarkdownUtils.test.ts
More file actions
40 lines (34 loc) · 1.94 KB
/
markdownUtils.test.ts
File metadata and controls
40 lines (34 loc) · 1.94 KB
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
40
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as marked from 'marked';
import { PlainTextRenderer } from '../../github/markdownUtils';
describe('PlainTextRenderer', () => {
it('should escape inline code by default', () => {
const renderer = new PlainTextRenderer();
const result = marked.parse('rename the `Foo` class', { renderer, smartypants: true });
assert.strictEqual(result.trim(), 'rename the \\`Foo\\` class');
});
it('should preserve inline code when allowSimpleMarkdown is true', () => {
const renderer = new PlainTextRenderer(true);
const result = marked.parse('rename the `Foo` class', { renderer, smartypants: true });
assert.strictEqual(result.trim(), 'rename the `Foo` class');
});
it('should handle multiple inline code spans', () => {
const renderer = new PlainTextRenderer(true);
const result = marked.parse('rename the `Foo` class to `Bar`', { renderer, smartypants: true });
assert.strictEqual(result.trim(), 'rename the `Foo` class to `Bar`');
});
it('should still escape when allowSimpleMarkdown is false', () => {
const renderer = new PlainTextRenderer(false);
const result = marked.parse('rename the `Foo` class to `Bar`', { renderer, smartypants: true });
assert.strictEqual(result.trim(), 'rename the \\`Foo\\` class to \\`Bar\\`');
});
it('should strip all formatting by default', () => {
const renderer = new PlainTextRenderer(false);
const result = marked.parse('rename the `Foo` class to **`Bar`** and make it *italic*', { renderer, smartypants: true });
assert.strictEqual(result.trim(), 'rename the \\`Foo\\` class to \\`Bar\\` and make it italic');
});
});