ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / emmet / src / test / abbreviationAction.test.ts 559 строк · изменён 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
import 'mocha' ;
import * as assert from 'assert' ;
import { Selection, workspace, CancellationTokenSource, CompletionTriggerKind, ConfigurationTarget, CompletionContext } from 'vscode' ;
import { withRandomFileEditor, closeAllEditors } from './testUtils' ;
import { expandEmmetAbbreviation } from '../abbreviationActions' ;
import { DefaultCompletionItemProvider } from '../defaultCompletionProvider' ;
const completionProvider = new DefaultCompletionItemProvider ( ) ;
htmlContents
invokeCompletionContext CompletionContext
triggerKind CompletionTriggerKind Invoke
triggerCharacter
closeAllEditors
editor _doc
editor selection
assert editor document
editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
assert completionPromise
completionList completionPromise
assert completionList completionList items completionList items length
completionList
assert completionList items label
assert completionList items documentation
htmlContents editor _doc
editor selection
assert editor document htmlContents
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
assert completionPromise
htmlContents editor _doc
editor selection
assert editor document htmlContents
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
assert completionPromise
fileContents
fileContents editor _doc
editor selection
assert editor document fileContents
fileContents
fileContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
assert completionPromise
htmlContents editor _doc
editor selection
expandPromise language
expandPromise
expandPromise
assert editor document htmlContents
abbreviation
expandedText
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
assert
completionList completionPromise
completionList completionList items completionList items length
assert
emmetCompletionItem completionList items
assert emmetCompletionItem label expandedText
assert emmetCompletionItem documentation expandedText
assert emmetCompletionItem filterText abbreviation
htmlContents editor _doc
editor selection
assert editor document htmlContents
styleAttributeContent
styleAttributeContent editor _doc
editor selection
expandPromise
expandPromise
expandPromise
assert editor document styleAttributeContent
abbreviation
expandedText
editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
assert
completionList completionPromise
completionList completionList items completionList items length
assert
emmetCompletionItem completionList items
assert emmetCompletionItem label expandedText
assert emmetCompletionItem documentation expandedText
assert emmetCompletionItem filterText abbreviation
htmlContents editor _doc
editor selection
expandPromise
expandPromise
expandPromise
assert editor document htmlContents
abbreviation
expandedText
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
assert
completionList completionPromise
completionList completionList items completionList items length
assert
emmetCompletionItem completionList items
assert emmetCompletionItem label abbreviation
assert emmetCompletionItem documentation expandedText
htmlContents editor _doc
editor selection
assert editor document htmlContents
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
assert completionPromise
oldConfig workspace globalValue
workspace ConfigurationTarget Global
htmlContents editor _doc
editor selection
expandPromise
expandPromise
expandPromise
assert editor document htmlContents
workspace oldConfig ConfigurationTarget Global
abbreviation
expandedText
oldConfig workspace globalValue
workspace ConfigurationTarget Global
htmlContents editor _doc
editor selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
assert
completionList completionPromise
completionList completionList items completionList items length
assert
emmetCompletionItem completionList items
assert emmetCompletionItem label abbreviation
assert emmetCompletionItem documentation expandedText
workspace oldConfig ConfigurationTarget Global
oldConfig workspace globalValue
workspace ConfigurationTarget Global
workspace oldConfig ConfigurationTarget Global
oldValueForSyntaxProfiles workspace
closeAllEditors
editor _doc
editor selection
language
assert editor document
editor _doc
editor selection
language
assert editor document
workspace jsx ConfigurationTarget Global
editor _doc
editor selection
language
assert editor document
workspace oldValueForSyntaxProfiles oldValueForSyntaxProfiles globalValue ConfigurationTarget Global
editor _doc
editor selection
language
assert editor document
editor _doc
editor selection
language
assert editor document
editor _doc
editor selection
language
assert editor document
htmlContents
htmlContents
htmlContents
syntax selection Selection abbreviation expandedText shouldFail Thenable
htmlContents syntax editor _doc
editor selection selection
expandPromise
expandPromise
shouldFail
assert
expandPromise
assert editor document htmlContents abbreviation expandedText
selection Selection abbreviation expandedText shouldFail Thenable
htmlContents editor _doc
editor selection selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
completionPromise
shouldFail
assert
completionList completionPromise
completionList completionList items completionList items length
shouldFail
assert
emmetCompletionItem completionList items
assert emmetCompletionItem label abbreviation
assert emmetCompletionItem documentation expandedText
syntax fileContents selection Selection Thenable
fileContents syntax editor _doc
editor selection selection
cancelSrc
completionPromise completionProvider editor document editor selection active cancelSrc token invokeCompletionContext
assert completionPromise
const
=
`
<body class="header">
<ul class="nav main">
<li class="item1">img</li>
<li class="item2">hithere</li>
ul>li
ul>li*2
ul>li.item$*2
ul>li.item$@44*2
<div i
</ul>
<style>
.boo {
display: dn; m10
}
</style>
<span></span>
(ul>li.item$)*2
(ul>li.item$)*2+span
(div>dl>(dt+dd)*2)
<script type="text/html">
span.hello
</script>
<script type="text/javascript">
span.bye
</script>
</body>
`
;
const
:
=
{
:
.
,
:
undefined
,
}
;
suite
(
'Tests for Expand Abbreviations (HTML)'
,
(
)
=>
{
teardown
(
)
;
test
(
'Expand snippets (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
3
,
23
,
3
,
23
)
,
'img'
,
'<img src=\"\" alt=\"\">'
)
;
}
)
;
test
(
'Expand snippets in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
3
,
23
,
3
,
23
)
,
'img'
,
'<img src=\"\" alt=\"\">'
)
;
}
)
;
test
(
'Expand snippets when no parent node (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
'img'
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
3
,
0
,
3
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<img src=\"\" alt=\"\">'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand snippets when no parent node in completion list (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
'img'
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
3
,
0
,
3
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
.
strictEqual
(
!
,
false
,
` Got unexpected undefined instead of a completion promise `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
await
;
.
strictEqual
(
&&
.
&&
.
.
>
0
,
true
)
;
if
(
)
{
.
strictEqual
(
.
[
0
]
.
,
'img'
)
;
.
strictEqual
(
(
(
<
string
>
.
[
0
]
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
'<img src=\"\" alt=\"\">'
)
;
}
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
5
,
25
,
5
,
25
)
,
'ul>li'
,
'<ul>\n\t\t\t<li></li>\n\t\t</ul>'
)
;
}
)
;
test
(
'Expand abbreviation in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
5
,
25
,
5
,
25
)
,
'ul>li'
,
'<ul>\n\t<li></li>\n</ul>'
)
;
}
)
;
test
(
'Expand text that is neither an abbreviation nor a snippet to tags (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
4
,
20
,
4
,
27
)
,
'hithere'
,
'<hithere></hithere>'
)
;
}
)
;
test
(
'Do not Expand text that is neither an abbreviation nor a snippet to tags in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
4
,
20
,
4
,
27
)
,
'hithere'
,
'<hithere></hithere>'
,
true
)
;
}
)
;
test
(
'Expand abbreviation with repeaters (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
6
,
27
,
6
,
27
)
,
'ul>li*2'
,
'<ul>\n\t\t\t<li></li>\n\t\t\t<li></li>\n\t\t</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with repeaters in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
6
,
27
,
6
,
27
)
,
'ul>li*2'
,
'<ul>\n\t<li></li>\n\t<li></li>\n</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
7
,
33
,
7
,
33
)
,
'ul>li.item$*2'
,
'<ul>\n\t\t\t<li class="item1"></li>\n\t\t\t<li class="item2"></li>\n\t\t</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
7
,
33
,
7
,
33
)
,
'ul>li.item$*2'
,
'<ul>\n\t<li class="item1"></li>\n\t<li class="item2"></li>\n</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters with offset (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
8
,
36
,
8
,
36
)
,
'ul>li.item$@44*2'
,
'<ul>\n\t\t\t<li class="item44"></li>\n\t\t\t<li class="item45"></li>\n\t\t</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters with offset in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
8
,
36
,
8
,
36
)
,
'ul>li.item$@44*2'
,
'<ul>\n\t<li class="item44"></li>\n\t<li class="item45"></li>\n</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters in groups (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
17
,
16
,
17
,
16
)
,
'(ul>li.item$)*2'
,
'<ul>\n\t\t<li class="item1"></li>\n\t</ul>\n\t<ul>\n\t\t<li class="item2"></li>\n\t</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters in groups in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
17
,
16
,
17
,
16
)
,
'(ul>li.item$)*2'
,
'<ul>\n\t<li class="item1"></li>\n</ul>\n<ul>\n\t<li class="item2"></li>\n</ul>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters in groups with sibling in the end (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
18
,
21
,
18
,
21
)
,
'(ul>li.item$)*2+span'
,
'<ul>\n\t\t<li class="item1"></li>\n\t</ul>\n\t<ul>\n\t\t<li class="item2"></li>\n\t</ul>\n\t<span></span>'
)
;
}
)
;
test
(
'Expand abbreviation with numbered repeaters in groups with sibling in the end in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
18
,
21
,
18
,
21
)
,
'(ul>li.item$)*2+span'
,
'<ul>\n\t<li class="item1"></li>\n</ul>\n<ul>\n\t<li class="item2"></li>\n</ul>\n<span></span>'
)
;
}
)
;
test
(
'Expand abbreviation with nested groups (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
19
,
19
,
19
,
19
)
,
'(div>dl>(dt+dd)*2)'
,
'<div>\n\t\t<dl>\n\t\t\t<dt></dt>\n\t\t\t<dd></dd>\n\t\t\t<dt></dt>\n\t\t\t<dd></dd>\n\t\t</dl>\n\t</div>'
)
;
}
)
;
test
(
'Expand abbreviation with nested groups in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
19
,
19
,
19
,
19
)
,
'(div>dl>(dt+dd)*2)'
,
'<div>\n\t<dl>\n\t\t<dt></dt>\n\t\t<dd></dd>\n\t\t<dt></dt>\n\t\t<dd></dd>\n\t</dl>\n</div>'
)
;
}
)
;
test
(
'Expand tag that is opened, but not closed (HTML)'
,
(
)
=>
{
return
testExpandAbbreviation
(
'html'
,
new
Selection
(
9
,
6
,
9
,
6
)
,
'<div'
,
'<div></div>'
)
;
}
)
;
test
(
'Do not Expand tag that is opened, but not closed in completion list (HTML)'
,
(
)
=>
{
return
testHtmlCompletionProvider
(
new
Selection
(
9
,
6
,
9
,
6
)
,
'<div'
,
'<div></div>'
,
true
)
;
}
)
;
test
(
'No expanding text inside open tag (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
2
,
4
,
2
,
4
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside open tag in completion list (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
(
,
)
=>
{
.
=
new
Selection
(
2
,
4
,
2
,
4
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
.
strictEqual
(
!
,
true
,
` Got unexpected comapletion promise instead of undefined `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside open tag when there is no closing tag (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
9
,
8
,
9
,
8
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside open tag when there is no closing tag in completion list (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
(
,
)
=>
{
.
=
new
Selection
(
9
,
8
,
9
,
8
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
.
strictEqual
(
!
,
true
,
` Got unexpected comapletion promise instead of undefined `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside open tag when there is no closing tag when there is no parent node (HTML)'
,
(
)
=>
{
const
=
'<img s'
;
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text in completion list inside open tag when there is no closing tag when there is no parent node (HTML)'
,
(
)
=>
{
const
=
'<img s'
;
return
withRandomFileEditor
(
,
'html'
,
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
.
strictEqual
(
!
,
true
,
` Got unexpected comapletion promise instead of undefined `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand css when inside style tag (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
13
,
16
,
13
,
19
)
;
const
=
expandEmmetAbbreviation
(
{
:
'css'
}
)
;
if
(
!
)
{
return
Promise
.
resolve
(
)
;
}
await
;
.
strictEqual
(
.
.
getText
(
)
,
.
replace
(
'm10'
,
'margin: 10px;'
)
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand css when inside style tag in completion list (HTML)'
,
(
)
=>
{
const
=
'm10'
;
const
=
'margin: 10px;'
;
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
13
,
16
,
13
,
19
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding m10 `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
await
;
if
(
!
||
!
.
||
!
.
.
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding m10 `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
.
[
0
]
;
.
strictEqual
(
.
,
,
` Label of completion item doesnt match. `
)
;
.
strictEqual
(
(
(
<
string
>
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
,
` Docs of completion item doesnt match. `
)
;
.
strictEqual
(
.
,
,
` FilterText of completion item doesnt match. `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside style tag if position is not for property name (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
13
,
14
,
13
,
14
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand css when inside style attribute (HTML)'
,
(
)
=>
{
const
=
'<div style="m10" class="hello"></div>'
;
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
15
,
0
,
15
)
;
const
=
expandEmmetAbbreviation
(
null
)
;
if
(
!
)
{
return
Promise
.
resolve
(
)
;
}
await
;
.
strictEqual
(
.
.
getText
(
)
,
.
replace
(
'm10'
,
'margin: 10px;'
)
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand css when inside style attribute in completion list (HTML)'
,
(
)
=>
{
const
=
'm10'
;
const
=
'margin: 10px;'
;
return
withRandomFileEditor
(
'<div style="m10" class="hello"></div>'
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
15
,
0
,
15
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding m10 `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
await
;
if
(
!
||
!
.
||
!
.
.
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding m10 `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
.
[
0
]
;
.
strictEqual
(
.
,
,
` Label of completion item doesnt match. `
)
;
.
strictEqual
(
(
(
<
string
>
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
,
` Docs of completion item doesnt match. `
)
;
.
strictEqual
(
.
,
,
` FilterText of completion item doesnt match. `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand html when inside script tag with html type (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
21
,
12
,
21
,
12
)
;
const
=
expandEmmetAbbreviation
(
null
)
;
if
(
!
)
{
return
Promise
.
resolve
(
)
;
}
await
;
.
strictEqual
(
.
.
getText
(
)
,
.
replace
(
'span.hello'
,
'<span class="hello"></span>'
)
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand html in completion list when inside script tag with html type (HTML)'
,
(
)
=>
{
const
=
'span.hello'
;
const
=
'<span class="hello"></span>'
;
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
21
,
12
,
21
,
12
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding span.hello `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
await
;
if
(
!
||
!
.
||
!
.
.
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding span.hello `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
.
[
0
]
;
.
strictEqual
(
.
,
,
` Label of completion item doesnt match. `
)
;
.
strictEqual
(
(
(
<
string
>
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
,
` Docs of completion item doesnt match. `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside script tag with javascript type (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
24
,
12
,
24
,
12
)
;
await
expandEmmetAbbreviation
(
null
)
;
.
strictEqual
(
.
.
getText
(
)
,
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text in completion list inside script tag with javascript type (HTML)'
,
(
)
=>
{
return
withRandomFileEditor
(
,
'html'
,
(
,
)
=>
{
.
=
new
Selection
(
24
,
12
,
24
,
12
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
.
strictEqual
(
!
,
true
,
` Got unexpected comapletion promise instead of undefined `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand html when inside script tag with javascript type if js is mapped to html (HTML)'
,
async
(
)
=>
{
const
=
.
getConfiguration
(
'emmet'
)
.
inspect
(
'includeLanguages'
)
?.
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'includeLanguages'
,
{
'javascript'
:
'html'
}
,
.
)
;
await
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
24
,
10
,
24
,
10
)
;
const
=
expandEmmetAbbreviation
(
null
)
;
if
(
!
)
{
return
Promise
.
resolve
(
)
;
}
await
;
.
strictEqual
(
.
.
getText
(
)
,
.
replace
(
'span.bye'
,
'<span class="bye"></span>'
)
)
;
}
)
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'includeLanguages'
,
,
.
)
;
}
)
;
test
(
'Expand html in completion list when inside script tag with javascript type if js is mapped to html (HTML)'
,
async
(
)
=>
{
const
=
'span.bye'
;
const
=
'<span class="bye"></span>'
;
const
=
.
getConfiguration
(
'emmet'
)
.
inspect
(
'includeLanguages'
)
?.
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'includeLanguages'
,
{
'javascript'
:
'html'
}
,
.
)
;
await
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
24
,
10
,
24
,
10
)
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding span.bye `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
await
;
if
(
!
||
!
.
||
!
.
.
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding span.bye `
)
;
return
Promise
.
resolve
(
)
;
}
const
=
.
[
0
]
;
.
strictEqual
(
.
,
,
` Label of completion item ( ${ emmetCompletionItem. label} ) doesnt match. `
)
;
.
strictEqual
(
(
(
<
string
>
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
,
` Docs of completion item doesnt match. `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'includeLanguages'
,
,
.
)
;
}
)
;
test
(
'No expanding when html is excluded in the settings in completion list'
,
async
(
)
=>
{
const
=
.
getConfiguration
(
'emmet'
)
.
inspect
(
'excludeLanguages'
)
?.
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'excludeLanguages'
,
[
'html'
]
,
.
)
;
await
testHtmlCompletionProvider
(
new
Selection
(
9
,
6
,
9
,
6
)
,
''
,
''
,
true
)
;
await
.
getConfiguration
(
'emmet'
)
.
update
(
'excludeLanguages'
,
,
.
)
;
}
)
;
}
)
;
suite
(
'Tests for jsx, xml and xsl'
,
(
)
=>
{
const
=
.
getConfiguration
(
'emmet'
)
.
inspect
(
'syntaxProfiles'
)
;
teardown
(
)
;
test
(
'Expand abbreviation with className instead of class in jsx'
,
(
)
=>
{
return
withRandomFileEditor
(
'ul.nav'
,
'javascriptreact'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
{
:
'javascriptreact'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<ul className="nav"></ul>'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation with self closing tags for jsx'
,
(
)
=>
{
return
withRandomFileEditor
(
'img'
,
'javascriptreact'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
{
:
'javascriptreact'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<img src="" alt="" />'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation with single quotes for jsx'
,
async
(
)
=>
{
await
.
getConfiguration
(
'emmet'
)
.
update
(
'syntaxProfiles'
,
{
:
{
'attr_quotes'
:
'single'
}
}
,
.
)
;
return
withRandomFileEditor
(
'img'
,
'javascriptreact'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
{
:
'javascriptreact'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<img src=\'\' alt=\'\' />'
)
;
return
.
getConfiguration
(
'emmet'
)
.
update
(
'syntaxProfiles'
,
?
.
:
undefined
,
.
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation with self closing tags for xml'
,
(
)
=>
{
return
withRandomFileEditor
(
'img'
,
'xml'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
{
:
'xml'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<img src="" alt=""/>'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation with no self closing tags for html'
,
(
)
=>
{
return
withRandomFileEditor
(
'img'
,
'html'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
6
,
0
,
6
)
;
await
expandEmmetAbbreviation
(
{
:
'html'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'<img src="" alt="">'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'Expand abbreviation with condition containing less than sign for jsx'
,
(
)
=>
{
return
withRandomFileEditor
(
'if (foo < 10) { span.bar'
,
'javascriptreact'
,
async
(
,
)
=>
{
.
=
new
Selection
(
0
,
27
,
0
,
27
)
;
await
expandEmmetAbbreviation
(
{
:
'javascriptreact'
}
)
;
.
strictEqual
(
.
.
getText
(
)
,
'if (foo < 10) { <span className="bar"></span>'
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
)
;
test
(
'No expanding text inside open tag in completion list (jsx)'
,
(
)
=>
{
return
testNoCompletion
(
'jsx'
,
,
new
Selection
(
2
,
4
,
2
,
4
)
)
;
}
)
;
test
(
'No expanding tag that is opened, but not closed in completion list (jsx)'
,
(
)
=>
{
return
testNoCompletion
(
'jsx'
,
,
new
Selection
(
9
,
6
,
9
,
6
)
)
;
}
)
;
test
(
'No expanding text inside open tag when there is no closing tag in completion list (jsx)'
,
(
)
=>
{
return
testNoCompletion
(
'jsx'
,
,
new
Selection
(
9
,
8
,
9
,
8
)
)
;
}
)
;
test
(
'No expanding text in completion list inside open tag when there is no closing tag when there is no parent node (jsx)'
,
(
)
=>
{
return
testNoCompletion
(
'jsx'
,
'<img s'
,
new
Selection
(
0
,
6
,
0
,
6
)
)
;
}
)
;
}
)
;
function
testExpandAbbreviation
(
:
string
,
:
,
:
string
,
:
string
,
?
:
boolean
)
:
<
any
>
{
return
withRandomFileEditor
(
,
,
async
(
,
)
=>
{
.
=
;
const
=
expandEmmetAbbreviation
(
null
)
;
if
(
!
)
{
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding ${ abbreviation} to ${ expandedText} `
)
;
}
return
Promise
.
resolve
(
)
;
}
await
;
.
strictEqual
(
.
.
getText
(
)
,
.
replace
(
,
)
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
function
testHtmlCompletionProvider
(
:
,
:
string
,
:
string
,
?
:
boolean
)
:
<
any
>
{
return
withRandomFileEditor
(
,
'html'
,
async
(
,
)
=>
{
.
=
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
if
(
!
)
{
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding ${ abbreviation} to ${ expandedText} `
)
;
}
return
Promise
.
resolve
(
)
;
}
const
=
await
;
if
(
!
||
!
.
||
!
.
.
)
{
if
(
!
)
{
.
strictEqual
(
1
,
2
,
` Problem with expanding ${ abbreviation} to ${ expandedText} `
)
;
}
return
Promise
.
resolve
(
)
;
}
const
=
.
[
0
]
;
.
strictEqual
(
.
,
,
` Label of completion item doesnt match. `
)
;
.
strictEqual
(
(
(
<
string
>
.
)
||
''
)
.
replace
(
/ \| / g
,
''
)
,
,
` Docs of completion item doesnt match. `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}
function
testNoCompletion
(
:
string
,
:
string
,
:
)
:
<
any
>
{
return
withRandomFileEditor
(
,
,
(
,
)
=>
{
.
=
;
const
=
new
CancellationTokenSource
(
)
;
const
=
.
provideCompletionItems
(
.
,
.
.
,
.
,
)
;
.
strictEqual
(
!
,
true
,
` Got unexpected comapletion promise instead of undefined `
)
;
return
Promise
.
resolve
(
)
;
}
)
;
}