forked from docsifyjs/docsify
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender-util.test.js
43 lines (39 loc) · 1.56 KB
/
render-util.test.js
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
41
42
43
const { removeAtag } = require(`${SRC_PATH}/core/render/utils`);
const { tree } = require(`${SRC_PATH}/core/render/tpl`);
// Suite
// -----------------------------------------------------------------------------
describe('core/render/utils', () => {
// removeAtag()
// ---------------------------------------------------------------------------
describe('removeAtag()', () => {
test('removeAtag from a link', () => {
const result = removeAtag('<a href="www.example.com">content</a>');
expect(result).toEqual('content');
});
});
});
describe('core/render/tpl', () => {
test('remove html tag in tree', () => {
const result = tree([
{
level: 2,
slug: '#/cover?id=basic-usage',
title: '<span style="color:red">Basic usage</span>',
},
{
level: 2,
slug: '#/cover?id=custom-background',
title: 'Custom background',
},
{
level: 2,
slug: '#/cover?id=test',
title:
'<img src="/docs/_media/favicon.ico" data-origin="/_media/favicon.ico" alt="ico">Test',
},
]);
expect(result).toEqual(
`<ul class="app-sub-sidebar"><li><a class="section-link" href="#/cover?id=basic-usage" title="Basic usage"><span style="color:red">Basic usage</span></a></li><li><a class="section-link" href="#/cover?id=custom-background" title="Custom background">Custom background</a></li><li><a class="section-link" href="#/cover?id=test" title="Test"><img src="/docs/_media/favicon.ico" data-origin="/_media/favicon.ico" alt="ico">Test</a></li></ul>`
);
});
});