forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
89 lines (66 loc) · 2.81 KB
/
Copy pathutils.ts
File metadata and controls
89 lines (66 loc) · 2.81 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { ansi2md, convertHTMLEntities, links2md } from '../utils';
describe('cli-scripts', () => {
describe('docs/utils', () => {
describe('ansi2md', () => {
it('should not affect regular text', () => {
const result = ansi2md('hello world');
expect(result).toEqual('hello world');
});
it('should strip yellow', () => {
const result = ansi2md('hello \u001b[33mworld\u001b[39m');
expect(result).toEqual('hello world');
});
it('should mark cyan as md code', () => {
const result = ansi2md('hello \u001b[36mworld\u001b[39m');
expect(result).toEqual('hello `world`');
});
it('should mark bold as md bold', () => {
const result = ansi2md('hello \u001b[1mworld\u001b[22m');
expect(result).toEqual('hello **world**');
});
});
describe('links2md', () => {
it('should work with empty string', () => {
const result = links2md('');
expect(result).toEqual('');
});
it('should work with multiple lines', () => {
const result = links2md('hello\nworld!\n');
expect(result).toEqual('hello\nworld!\n');
});
it('should replace a link with md version', () => {
const website = 'https://ionicframework.com';
const result = links2md(website);
expect(result).toEqual(`[${website}](${website})`);
});
it('should replace links with md', () => {
const website = 'https://ionicframework.com';
const result = links2md(`visit my cool website: **${website}**\nthank you`);
expect(result).toEqual(`visit my cool website: **[${website}](${website})**\nthank you`);
});
it('should escape footnote numbers', () => {
const website = 'https://ionicframework.com';
const result = links2md(`See the docs[1]\n\n[1]: **${website}**`);
expect(result).toEqual(`See the docs\\[1\\]\n\n\\[1\\]: **[${website}](${website})**`);
});
});
describe('convertHTMLEntities', () => {
it('should not affect regular text', () => {
const result = convertHTMLEntities('hello world');
expect(result).toEqual('hello world');
});
it('should not affect symbols that are not tags', () => {
const result = convertHTMLEntities('I <3 TypeScript');
expect(result).toEqual('I <3 TypeScript');
});
it('should convert tag-like symbols', () => {
const result = convertHTMLEntities('in the resources/<platform> folder');
expect(result).toEqual('in the resources/<platform> folder');
});
it('should respect tag-like symbols in code ticks', () => {
const result = convertHTMLEntities('in the `resources/<platform>` folder');
expect(result).toEqual('in the `resources/<platform>` folder');
});
});
});
});