Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0b3c33b8
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0b3c33b8
编写于
2月 10, 2019
作者:
M
Matthew Kwiecien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding unit tests to check for className when file is jsx.
上级
7221f92e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
210 addition
and
170 deletion
+210
-170
extensions/emmet/src/test/wrapWithAbbreviation.test.ts
extensions/emmet/src/test/wrapWithAbbreviation.test.ts
+210
-170
未找到文件。
extensions/emmet/src/test/wrapWithAbbreviation.test.ts
浏览文件 @
0b3c33b8
...
@@ -63,6 +63,22 @@ const wrapInlineElementExpectedFormatFalse = `
...
@@ -63,6 +63,22 @@ const wrapInlineElementExpectedFormatFalse = `
</ul>
</ul>
`
;
`
;
const
wrapMultiLineJsxExpected
=
`
<ul class="nav main">
<div className="hello">
<li class="item1">img</li>
<li class="item2">$hithere</li>
</div>
</ul>
`
;
const
wrapIndividualLinesJsxExpected
=
`
<ul class="nav main">
<div className="hello1"><li class="item1">img</li></div>
<div className="hello2"><li class="item2">$hithere</li></div>
</ul>
`
;
suite
(
'
Tests for Wrap with Abbreviations
'
,
()
=>
{
suite
(
'
Tests for Wrap with Abbreviations
'
,
()
=>
{
teardown
(
closeAllEditors
);
teardown
(
closeAllEditors
);
...
@@ -135,219 +151,219 @@ suite('Tests for Wrap with Abbreviations', () => {
...
@@ -135,219 +151,219 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
</ul>
`
;
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
2
,
0
,
2
,
0
)];
editor
.
selections
=
[
new
Selection
(
2
,
0
,
2
,
0
)];
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
li.hello|c
'
});
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
li.hello|c
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap with abbreviation entire node when cursor is on opening tag
'
,
()
=>
{
test
(
'
Wrap with abbreviation entire node when cursor is on opening tag
'
,
()
=>
{
const
contents
=
`
const
contents
=
`
<div class="nav main">
hello
</div>
`
;
const
expectedContents
=
`
<div>
<div class="nav main">
<div class="nav main">
hello
hello
</div>
</div>
`
;
</div>
const
expectedContents
=
`
`
;
<div>
<div class="nav main">
hello
</div>
</div>
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
1
,
1
,
1
,
1
)];
editor
.
selections
=
[
new
Selection
(
1
,
1
,
1
,
1
)];
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
div
'
});
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
div
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap with abbreviation entire node when cursor is on closing tag
'
,
()
=>
{
test
(
'
Wrap with abbreviation entire node when cursor is on closing tag
'
,
()
=>
{
const
contents
=
`
const
contents
=
`
<div class="nav main">
hello
</div>
`
;
const
expectedContents
=
`
<div>
<div class="nav main">
<div class="nav main">
hello
hello
</div>
</div>
`
;
</div>
const
expectedContents
=
`
`
;
<div>
<div class="nav main">
hello
</div>
</div>
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
3
,
1
,
3
,
1
)];
editor
.
selections
=
[
new
Selection
(
3
,
1
,
3
,
1
)];
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
div
'
});
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
div
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap with multiline abbreviation doesnt add extra spaces
'
,
()
=>
{
test
(
'
Wrap with multiline abbreviation doesnt add extra spaces
'
,
()
=>
{
// Issue #29898
// Issue #29898
const
contents
=
`
const
contents
=
`
hello
hello
`
;
`
;
const
expectedContents
=
`
const
expectedContents
=
`
<ul>
<ul>
<li><a href="">hello</a></li>
<li><a href="">hello</a></li>
</ul>
</ul>
`
;
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
1
,
2
,
1
,
2
)];
editor
.
selections
=
[
new
Selection
(
1
,
2
,
1
,
2
)];
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
ul>li>a
'
});
const
promise
=
wrapWithAbbreviation
({
abbreviation
:
'
ul>li>a
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap returned undefined instead of promise.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap individual lines with abbreviation
'
,
()
=>
{
test
(
'
Wrap individual lines with abbreviation
'
,
()
=>
{
const
contents
=
`
const
contents
=
`
<ul class="nav main">
<ul class="nav main">
<li class="item1">This $10 is not a tabstop</li>
<li class="item1">This $10 is not a tabstop</li>
<li class="item2">hi.there</li>
<li class="item2">hi.there</li>
</ul>
</ul>
`
;
`
;
const
wrapIndividualLinesExpected
=
`
const
wrapIndividualLinesExpected
=
`
<ul class="nav main">
<ul class="nav main">
<ul>
<ul>
<li class="hello1"><li class="item1">This $10 is not a tabstop</li></li>
<li class="hello1"><li class="item1">This $10 is not a tabstop</li></li>
<li class="hello2"><li class="item2">hi.there</li></li>
<li class="hello2"><li class="item2">hi.there</li></li>
</ul>
</ul>
</ul>
</ul>
`
;
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
2
,
2
,
3
,
33
)];
editor
.
selections
=
[
new
Selection
(
2
,
2
,
3
,
33
)];
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*
'
});
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap individual lines with abbreviation with extra space selected
'
,
()
=>
{
test
(
'
Wrap individual lines with abbreviation with extra space selected
'
,
()
=>
{
const
contents
=
`
const
contents
=
`
<ul class="nav main">
<ul class="nav main">
<li class="item1">img</li>
<li class="item1">img</li>
<li class="item2">hi.there</li>
<li class="item2">hi.there</li>
</ul>
`
;
const
wrapIndividualLinesExpected
=
`
<ul class="nav main">
<ul>
<li class="hello1"><li class="item1">img</li></li>
<li class="hello2"><li class="item2">hi.there</li></li>
</ul>
</ul>
</ul>
`
;
`
;
const
wrapIndividualLinesExpected
=
`
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
<ul class="nav main">
editor
.
selections
=
[
new
Selection
(
2
,
1
,
4
,
0
)];
<ul>
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*
'
});
<li class="hello1"><li class="item1">img</li></li>
if
(
!
promise
)
{
<li class="hello2"><li class="item2">hi.there</li></li>
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
</ul>
return
Promise
.
resolve
();
}
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
return
Promise
.
resolve
();
});
});
});
test
(
'
Wrap individual lines with abbreviation with comment filter
'
,
()
=>
{
const
contents
=
`
<ul class="nav main">
<li class="item1">img</li>
<li class="item2">hi.there</li>
</ul>
`
;
const
wrapIndividualLinesExpected
=
`
<ul class="nav main">
<ul>
<li class="hello"><li class="item1">img</li></li>
<!-- /.hello -->
<li class="hello"><li class="item2">hi.there</li></li>
<!-- /.hello -->
</ul>
</ul>
</ul>
`
;
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
2
,
1
,
4
,
0
)];
editor
.
selections
=
[
new
Selection
(
2
,
2
,
3
,
33
)];
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*
'
});
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello*|c
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap individual lines with abbreviation with comment filter
'
,
()
=>
{
test
(
'
Wrap individual lines with abbreviation and trim
'
,
()
=>
{
const
contents
=
`
const
contents
=
`
<ul class="nav main">
<ul class="nav main">
<li class="item1">img</li>
• lorem ipsum
<li class="item2">hi.there</li>
• lorem ipsum
</ul>
</ul>
`
;
`
;
const
wrapIndividualLinesExpected
=
`
const
wrapIndividualLinesExpected
=
`
<ul class="nav main">
<ul class="nav main">
<ul>
<ul>
<li class="hello"><li class="item1">img</li></li>
<li class="hello1">lorem ipsum</li>
<!-- /.hello -->
<li class="hello2">lorem ipsum</li>
<li class="hello"><li class="item2">hi.there</li></li>
<!-- /.hello -->
</ul>
</ul>
</ul>
</ul>
`
;
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
2
,
2
,
3
,
33
)];
editor
.
selections
=
[
new
Selection
(
2
,
3
,
3
,
16
)];
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello*|c
'
});
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*|t
'
});
if
(
!
promise
)
{
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
return
Promise
.
resolve
();
});
});
});
test
(
'
Wrap individual lines with abbreviation and trim
'
,
()
=>
{
return
promise
.
then
(()
=>
{
const
contents
=
`
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
<ul class="nav main">
return
Promise
.
resolve
();
• lorem ipsum
• lorem ipsum
</ul>
`
;
const
wrapIndividualLinesExpected
=
`
<ul class="nav main">
<ul>
<li class="hello1">lorem ipsum</li>
<li class="hello2">lorem ipsum</li>
</ul>
</ul>
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
_
)
=>
{
editor
.
selections
=
[
new
Selection
(
2
,
3
,
3
,
16
)];
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
:
'
ul>li.hello$*|t
'
});
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap Individual Lines with Abbreviation returned undefined.
'
);
return
Promise
.
resolve
();
}
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
wrapIndividualLinesExpected
);
return
Promise
.
resolve
();
});
});
});
});
});
});
test
(
'
Wrap with abbreviation and format set to false
'
,
()
=>
{
test
(
'
Wrap with abbreviation and format set to false
'
,
()
=>
{
return
workspace
.
getConfiguration
(
'
emmet
'
).
update
(
'
syntaxProfiles
'
,{
'
html
'
:
{
'
format
'
:
false
}
}
,
ConfigurationTarget
.
Global
).
then
(()
=>
{
return
workspace
.
getConfiguration
(
'
emmet
'
).
update
(
'
syntaxProfiles
'
,{
'
html
'
:
{
'
format
'
:
false
}
}
,
ConfigurationTarget
.
Global
).
then
(()
=>
{
...
@@ -384,11 +400,19 @@ suite('Tests for Wrap with Abbreviations', () => {
...
@@ -384,11 +400,19 @@ suite('Tests for Wrap with Abbreviations', () => {
return
testWrapWithAbbreviation
([
new
Selection
(
2
,
4
,
3
,
9
),
new
Selection
(
5
,
4
,
6
,
9
)],
'
div
'
,
wrapMultiLineExpected
,
htmlContentsForWrapMultiLineTests
);
return
testWrapWithAbbreviation
([
new
Selection
(
2
,
4
,
3
,
9
),
new
Selection
(
5
,
4
,
6
,
9
)],
'
div
'
,
wrapMultiLineExpected
,
htmlContentsForWrapMultiLineTests
);
});
});
test
(
'
Wrap multiline with abbreviation uses className for jsx files
'
,
()
=>
{
return
testWrapWithAbbreviation
([
new
Selection
(
2
,
2
,
3
,
33
)],
'
.hello
'
,
wrapMultiLineJsxExpected
,
htmlContentsForWrapTests
,
'
jsx
'
);
});
test
(
'
Wrap individual line with abbreviation uses className for jsx files
'
,
()
=>
{
return
testWrapIndividualLinesWithAbbreviation
([
new
Selection
(
2
,
2
,
3
,
33
)],
'
.hello$*
'
,
wrapIndividualLinesJsxExpected
,
htmlContentsForWrapTests
,
'
jsx
'
);
});
});
});
function
testWrapWithAbbreviation
(
selections
:
Selection
[],
abbreviation
:
string
,
expectedContents
:
string
,
input
:
string
=
htmlContentsForWrapTests
):
Thenable
<
any
>
{
function
testWrapWithAbbreviation
(
selections
:
Selection
[],
abbreviation
:
string
,
expectedContents
:
string
,
input
:
string
=
htmlContentsForWrapTests
,
fileExtension
:
string
=
'
html
'
):
Thenable
<
any
>
{
return
withRandomFileEditor
(
input
,
'
html
'
,
(
editor
,
_
)
=>
{
return
withRandomFileEditor
(
input
,
fileExtension
,
(
editor
,
_
)
=>
{
editor
.
selections
=
selections
;
editor
.
selections
=
selections
;
const
promise
=
wrapWithAbbreviation
({
abbreviation
});
const
promise
=
wrapWithAbbreviation
({
abbreviation
});
if
(
!
promise
)
{
if
(
!
promise
)
{
...
@@ -402,3 +426,19 @@ function testWrapWithAbbreviation(selections: Selection[], abbreviation: string,
...
@@ -402,3 +426,19 @@ function testWrapWithAbbreviation(selections: Selection[], abbreviation: string,
});
});
});
});
}
}
function
testWrapIndividualLinesWithAbbreviation
(
selections
:
Selection
[],
abbreviation
:
string
,
expectedContents
:
string
,
input
:
string
=
htmlContentsForWrapTests
,
fileExtension
:
string
=
'
html
'
):
Thenable
<
any
>
{
return
withRandomFileEditor
(
input
,
fileExtension
,
(
editor
,
_
)
=>
{
editor
.
selections
=
selections
;
const
promise
=
wrapIndividualLinesWithAbbreviation
({
abbreviation
});
if
(
!
promise
)
{
assert
.
equal
(
1
,
2
,
'
Wrap individual lines with Abbreviation returned undefined.
'
);
return
Promise
.
resolve
();
}
return
promise
.
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
});
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录