Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6d96f88c
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,发现更多精彩内容 >>
提交
6d96f88c
编写于
2月 19, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tests: global mime module is evil
上级
b7e9c828
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
46 deletion
+39
-46
src/vs/workbench/parts/files/test/browser/viewModel.test.ts
src/vs/workbench/parts/files/test/browser/viewModel.test.ts
+39
-46
未找到文件。
src/vs/workbench/parts/files/test/browser/viewModel.test.ts
浏览文件 @
6d96f88c
...
...
@@ -14,7 +14,7 @@ import {validateFileName} from 'vs/workbench/parts/files/browser/fileActions';
import
{
LocalFileChangeEvent
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
FileStat
}
from
'
vs/workbench/parts/files/common/explorerViewModel
'
;
function
createStat
(
path
,
name
,
isFolder
,
hasChildren
,
size
,
mtime
,
mime
)
{
function
createStat
(
path
,
name
,
isFolder
,
hasChildren
,
size
,
mtime
)
{
return
new
FileStat
(
toResource
(
path
),
isFolder
,
hasChildren
,
name
,
mtime
);
}
...
...
@@ -26,7 +26,7 @@ suite('Files - View Model', () => {
test
(
"
Properties
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
);
assert
.
strictEqual
(
s
.
isDirectoryResolved
,
false
);
assert
.
strictEqual
(
s
.
resource
.
fsPath
,
toResource
(
"
/path/to/stat
"
).
fsPath
);
...
...
@@ -34,28 +34,21 @@ suite('Files - View Model', () => {
assert
.
strictEqual
(
s
.
isDirectory
,
true
);
assert
.
strictEqual
(
s
.
hasChildren
,
true
);
assert
.
strictEqual
(
s
.
mtime
,
new
Date
(
d
).
getTime
());
assert
.
strictEqual
(
s
.
mime
,
undefined
);
assert
(
isArray
(
s
.
children
)
&&
s
.
children
.
length
===
0
);
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
,
"
text/plain; charset utf8
"
);
assert
.
strictEqual
(
s
.
mime
,
undefined
);
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
false
,
false
,
8096
,
d
,
"
text/plain; charset utf8
"
);
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
false
,
false
,
8096
,
d
);
assert
(
isUndefinedOrNull
(
s
.
children
));
s
=
createStat
(
"
/path/to/stat/sName.js
"
,
"
sName.js
"
,
false
,
false
,
8096
,
d
,
"
text/plain; charset utf8
"
);
assert
.
strictEqual
(
s
.
mime
,
'
text/javascript, text/plain
'
);
});
test
(
"
Add and Remove Child, check for hasChild
"
,
function
()
{
let
d
=
new
Date
().
getTime
()
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s2
=
createStat
(
"
/path/to/stat2
"
,
"
sName2
"
,
false
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
false
,
8096
,
d
);
let
s2
=
createStat
(
"
/path/to/stat2
"
,
"
sName2
"
,
false
,
false
,
8096
,
d
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
child2
=
createStat
(
"
/path/to/stat/bar.html
"
,
"
bar
"
,
false
,
false
,
8096
,
d
,
"
text/html
"
);
let
child3
=
createStat
(
"
/path/to/stat/bar.html
"
,
"
bar
"
,
false
,
false
,
8096
,
d
,
"
text/html
"
);
let
child4
=
createStat
(
"
/otherpath/to/other/otherbar.html
"
,
"
otherbar.html
"
,
false
,
false
,
8096
,
d
,
"
text/html
"
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
);
let
child2
=
createStat
(
"
/path/to/stat/bar.html
"
,
"
bar
"
,
false
,
false
,
8096
,
d
);
let
child3
=
createStat
(
"
/path/to/stat/bar.html
"
,
"
bar
"
,
false
,
false
,
8096
,
d
);
let
child4
=
createStat
(
"
/otherpath/to/other/otherbar.html
"
,
"
otherbar.html
"
,
false
,
false
,
8096
,
d
);
assert
.
throws
(
function
()
{
s2
.
addChild
(
child1
);
// Can not add into non directory
...
...
@@ -103,10 +96,10 @@ suite('Files - View Model', () => {
test
(
"
Move
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
false
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
false
,
false
,
8096
,
d
);
s1
.
addChild
(
s2
);
s2
.
addChild
(
s3
);
...
...
@@ -135,9 +128,9 @@ suite('Files - View Model', () => {
assert
.
strictEqual
(
s4
.
resource
.
fsPath
,
toResource
(
"
/
"
+
s4
.
name
).
fsPath
);
// Move a subtree with children
let
leaf
=
createStat
(
"
/leaf
"
,
"
leaf
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
leafC1
=
createStat
(
"
/leaf/folder
"
,
"
folder
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
leafCC2
=
createStat
(
"
/leaf/folder/index.html
"
,
"
index.html
"
,
true
,
false
,
8096
,
d
,
"
text/html
"
);
let
leaf
=
createStat
(
"
/leaf
"
,
"
leaf
"
,
true
,
false
,
8096
,
d
);
let
leafC1
=
createStat
(
"
/leaf/folder
"
,
"
folder
"
,
true
,
false
,
8096
,
d
);
let
leafCC2
=
createStat
(
"
/leaf/folder/index.html
"
,
"
index.html
"
,
true
,
false
,
8096
,
d
);
leaf
.
addChild
(
leafC1
);
leafC1
.
addChild
(
leafCC2
);
...
...
@@ -151,11 +144,11 @@ suite('Files - View Model', () => {
test
(
"
Rename
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s5
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
);
let
s5
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
);
assert
.
throws
(
function
()
{
s2
.
rename
(
null
);
...
...
@@ -173,7 +166,7 @@ suite('Files - View Model', () => {
s2
.
addChild
(
s3
);
s3
.
addChild
(
s4
);
let
s2renamed
=
createStat
(
"
/otherpath
"
,
"
otherpath
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
s2renamed
=
createStat
(
"
/otherpath
"
,
"
otherpath
"
,
true
,
true
,
8096
,
d
);
s2
.
rename
(
s2renamed
);
// Verify the paths have changed including children
...
...
@@ -182,7 +175,7 @@ suite('Files - View Model', () => {
assert
.
strictEqual
(
s3
.
resource
.
fsPath
,
toResource
(
"
/otherpath/to
"
).
fsPath
);
assert
.
strictEqual
(
s4
.
resource
.
fsPath
,
toResource
(
"
/otherpath/to/stat
"
).
fsPath
);
let
s4renamed
=
createStat
(
"
/otherpath/to/statother.js
"
,
"
statother.js
"
,
true
,
false
,
8096
,
d
,
"
text/javascript
"
);
let
s4renamed
=
createStat
(
"
/otherpath/to/statother.js
"
,
"
statother.js
"
,
true
,
false
,
8096
,
d
);
s4
.
rename
(
s4renamed
);
assert
.
strictEqual
(
s4
.
name
,
s4renamed
.
name
);
assert
.
strictEqual
(
s4
.
resource
.
fsPath
,
s4renamed
.
resource
.
fsPath
);
...
...
@@ -191,13 +184,13 @@ suite('Files - View Model', () => {
test
(
"
Find
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
child2
=
createStat
(
"
/path/to/stat/foo/bar.html
"
,
"
bar.html
"
,
false
,
false
,
8096
,
d
,
"
text/html
"
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
);
let
child2
=
createStat
(
"
/path/to/stat/foo/bar.html
"
,
"
bar.html
"
,
false
,
false
,
8096
,
d
);
s1
.
addChild
(
s2
);
s2
.
addChild
(
s3
);
...
...
@@ -219,13 +212,13 @@ suite('Files - View Model', () => {
test
(
"
Find with mixed case
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
s1
=
createStat
(
"
/
"
,
"
/
"
,
true
,
false
,
8096
,
d
);
let
s2
=
createStat
(
"
/path
"
,
"
path
"
,
true
,
false
,
8096
,
d
);
let
s3
=
createStat
(
"
/path/to
"
,
"
to
"
,
true
,
false
,
8096
,
d
);
let
s4
=
createStat
(
"
/path/to/stat
"
,
"
stat
"
,
true
,
false
,
8096
,
d
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
,
"
text/plain
"
);
let
child2
=
createStat
(
"
/path/to/stat/foo/bar.html
"
,
"
bar.html
"
,
false
,
false
,
8096
,
d
,
"
text/html
"
);
let
child1
=
createStat
(
"
/path/to/stat/foo
"
,
"
foo
"
,
true
,
false
,
8096
,
d
);
let
child2
=
createStat
(
"
/path/to/stat/foo/bar.html
"
,
"
bar.html
"
,
false
,
false
,
8096
,
d
);
s1
.
addChild
(
s2
);
s2
.
addChild
(
s3
);
...
...
@@ -244,8 +237,8 @@ suite('Files - View Model', () => {
test
(
"
Validate File Name (For Create)
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
sChild
=
createStat
(
"
/path/to/stat/alles.klar
"
,
"
alles.klar
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
);
let
sChild
=
createStat
(
"
/path/to/stat/alles.klar
"
,
"
alles.klar
"
,
true
,
true
,
8096
,
d
);
s
.
addChild
(
sChild
);
assert
(
validateFileName
(
s
,
null
)
!==
null
);
...
...
@@ -271,8 +264,8 @@ suite('Files - View Model', () => {
test
(
"
Validate File Name (For Rename)
"
,
function
()
{
let
d
=
new
Date
().
getTime
();
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
sChild
=
createStat
(
"
/path/to/stat/alles.klar
"
,
"
alles.klar
"
,
true
,
true
,
8096
,
d
,
"
text/plain
"
);
let
s
=
createStat
(
"
/path/to/stat
"
,
"
sName
"
,
true
,
true
,
8096
,
d
);
let
sChild
=
createStat
(
"
/path/to/stat/alles.klar
"
,
"
alles.klar
"
,
true
,
true
,
8096
,
d
);
s
.
addChild
(
sChild
);
assert
(
validateFileName
(
s
,
"
alles.klar
"
)
!==
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录