ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / markdown-language-features / src / test / engine.test.ts 122 строк · изменён 14 нояб., 04:52
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import * as assert from 'assert' ;
import 'mocha' ;
import * as vscode from 'vscode' ;
import { InMemoryDocument } from '../client/inMemoryDocument' ;
import { createNewMarkdownEngine } from './engine' ;
const testFileName = vscode. Uri. file ( 'test.md' ) ;
suite ( 'markdown.engine' , ( ) => {
suite ( 'rendering' , (
input
output
doc testFileName input
engine
assert engine doc html output
engine
assert engine input html output
input
engine
result engine input
assert result html
assert result containingImages
settingName
input
originalValue
originalValue vscode workspace settingName globalValue
vscode workspace settingName originalValue vscode ConfigurationTarget Global
style
vscode workspace settingName style vscode ConfigurationTarget Global
engine
assert
engine input html
engine
html engine input html
assert html
assert html
assert html
engine
assert
engine input html
engine
html engine html
assert html
assert html
engine
html engine html
assert html
engine
html engine html
assert html
)
=>
{
const
=
'# hello\n\nworld!'
;
const
=
'<h1 data-line="0" class="code-line" dir="auto" id="hello">hello</h1>\n'
+
'<p data-line="2" class="code-line" dir="auto">world!</p>\n'
;
test
(
'Renders a document'
,
async
(
)
=>
{
const
=
new
InMemoryDocument
(
,
)
;
const
=
createNewMarkdownEngine
(
)
;
.
strictEqual
(
(
await
.
render
(
)
)
.
,
)
;
}
)
;
test
(
'Renders a string'
,
async
(
)
=>
{
const
=
createNewMarkdownEngine
(
)
;
.
strictEqual
(
(
await
.
render
(
)
)
.
,
)
;
}
)
;
}
)
;
suite
(
'image-caching'
,
(
)
=>
{
const
=
' [](no-img.png)   '
;
test
(
'Extracts all images'
,
async
(
)
=>
{
const
=
createNewMarkdownEngine
(
)
;
const
=
await
.
render
(
)
;
.
deepStrictEqual
(
.
,
'<p data-line="0" class="code-line" dir="auto">'
+
'<img src="img.png" alt="" data-src="img.png"> '
+
'<a href="no-img.png" data-href="no-img.png"></a> '
+
'<img src="http://example.org/img.png" alt="" data-src="http://example.org/img.png"> '
+
'<img src="img.png" alt="" data-src="img.png"> '
+
'<img src="./img2.png" alt="" data-src="./img2.png">'
+
'</p>\n'
)
;
.
deepStrictEqual
(
[
...
.
]
,
[
'img.png'
,
'http://example.org/img.png'
,
'./img2.png'
]
)
;
}
)
;
}
)
;
suite
(
'front-matter'
,
(
)
=>
{
const
=
'preview.frontMatter'
;
const
=
'---\ntitle: Hello\n---\n\n# World'
;
let
:
string
|
undefined
;
suiteSetup
(
(
)
=>
{
=
.
.
getConfiguration
(
'markdown'
)
.
inspect < string >
(
)
?.
;
}
)
;
suiteTeardown
(
async
(
)
=>
{
await
.
.
getConfiguration
(
'markdown'
)
.
update
(
,
,
.
.
)
;
}
)
;
async
function
setStyle
(
:
string
)
{
await
.
.
getConfiguration
(
'markdown'
)
.
update
(
,
,
.
.
)
;
}
test
(
'Hides frontmatter when style is "hide"'
,
async
(
)
=>
{
await
setStyle
(
'hide'
)
;
const
=
createNewMarkdownEngine
(
)
;
.
strictEqual
(
(
await
.
render
(
)
)
.
,
'<h1 data-line="4" class="code-line" dir="auto" id="world">World</h1>\n'
)
;
}
)
;
test
(
'Renders frontmatter as a code block when style is "codeBlock"'
,
async
(
)
=>
{
await
setStyle
(
'codeBlock'
)
;
const
=
createNewMarkdownEngine
(
)
;
const
=
(
await
.
render
(
)
)
.
;
.
match
(
,
/ <pre[ ^ >] * class="[ ^ "] * frontmatter[ ^ "] * "[ ^ >] * >[ \s \S ] * <\/ pre> /
)
;
.
ok
(
.
includes
(
'title'
)
,
` Expected frontmatter content to be rendered. Got: ${ html} `
)
;
.
ok
(
.
includes
(
'<h1 data-line="4"'
)
,
` Expected body to render after frontmatter. Got: ${ html} `
)
;
}
)
;
test
(
'Renders frontmatter as a table when style is "table"'
,
async
(
)
=>
{
await
setStyle
(
'table'
)
;
const
=
createNewMarkdownEngine
(
)
;
.
strictEqual
(
(
await
.
render
(
)
)
.
,
'<table class="frontmatter" title="Frontmatter" data-vscode-context=\'{"webviewSection":"frontMatter"}\'><tbody><tr><th>title</th><td>Hello</td></tr></tbody></table>\n'
+
'<h1 data-line="4" class="code-line" dir="auto" id="world">World</h1>\n'
)
;
}
)
;
test
(
'Shows an error when frontmatter has invalid YAML'
,
async
(
)
=>
{
await
setStyle
(
'table'
)
;
const
=
createNewMarkdownEngine
(
)
;
const
=
(
await
.
render
(
'---\nfoo: [unclosed\n---\n\n# Body'
)
)
.
;
.
match
(
,
/ <div class="frontmatter-error"[ \s \S ] * <\/ div> /
)
;
.
ok
(
.
includes
(
'<h1 data-line="4"'
)
,
` Expected body to render after error. Got: ${ html} `
)
;
}
)
;
test
(
'Ignores frontmatter that is not at the start of the document'
,
async
(
)
=>
{
await
setStyle
(
'table'
)
;
const
=
createNewMarkdownEngine
(
)
;
const
=
(
await
.
render
(
'# World\n\n---\ntitle: Hello\n---'
)
)
.
;
.
ok
(
!
.
includes
(
'<table class="frontmatter">'
)
,
` Expected no frontmatter table. Got: ${ html} `
)
;
}
)
;
test
(
'Ignores frontmatter without a closing delimiter'
,
async
(
)
=>
{
await
setStyle
(
'table'
)
;
const
=
createNewMarkdownEngine
(
)
;
const
=
(
await
.
render
(
'---\ntitle: Hello\n\n# World'
)
)
.
;
.
ok
(
!
.
includes
(
'<table class="frontmatter">'
)
,
` Expected no frontmatter table. Got: ${ html} `
)
;
}
)
;
}
)
;
}
)
;