Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
41aba141
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,发现更多精彩内容 >>
提交
41aba141
编写于
12月 14, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Basic test for workspace recommendations
上级
e61b47b9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
128 addition
and
0 deletion
+128
-0
src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts
...sions/test/electron-browser/extensionsTipsService.test.ts
+128
-0
未找到文件。
src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts
0 → 100644
浏览文件 @
41aba141
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
os
from
'
os
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
uuid
=
require
(
'
vs/base/common/uuid
'
);
import
{
mkdirp
}
from
'
vs/base/node/pfs
'
;
import
{
IExtensionManagementService
,
IExtensionGalleryService
,
IExtensionTipsService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
ExtensionManagementService
}
from
'
vs/platform/extensionManagement/node/extensionManagementService
'
;
import
{
ExtensionTipsService
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionTipsService
'
;
import
{
ExtensionGalleryService
}
from
'
vs/platform/extensionManagement/node/extensionGalleryService
'
;
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
TestTextResourceConfigurationService
,
TestContextService
,
TestLifecycleService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
Model
as
EditorModel
}
from
'
vs/editor/common/model/model
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
testWorkspace
}
from
'
vs/platform/workspace/test/common/testWorkspace
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/node/fileService
'
;
import
extfs
=
require
(
'
vs/base/node/extfs
'
);
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
WorkspaceService
}
from
'
vs/workbench/services/configuration/node/configurationService
'
;
const
expectedWorkspaceRecommendations
=
[
'
eg2.tslint
'
,
'
dbaeumer.vscode-eslint
'
,
'
msjsdiag.debugger-for-chrome
'
];
function
setUpFolderWorkspace
(
folderName
:
string
):
TPromise
<
{
parentDir
:
string
,
folderDir
:
string
}
>
{
const
id
=
uuid
.
generateUuid
();
const
parentDir
=
path
.
join
(
os
.
tmpdir
(),
'
vsctests
'
,
id
);
return
setUpFolder
(
folderName
,
parentDir
).
then
(
folderDir
=>
({
parentDir
,
folderDir
}));
}
function
setUpFolder
(
folderName
:
string
,
parentDir
:
string
):
TPromise
<
string
>
{
const
folderDir
=
path
.
join
(
parentDir
,
folderName
);
const
workspaceSettingsDir
=
path
.
join
(
folderDir
,
'
.vscode
'
);
return
mkdirp
(
workspaceSettingsDir
,
493
).
then
(()
=>
{
const
configPath
=
path
.
join
(
workspaceSettingsDir
,
'
extensions.json
'
);
fs
.
writeFileSync
(
configPath
,
JSON
.
stringify
({
'
recommendations
'
:
expectedWorkspaceRecommendations
},
null
,
'
\t
'
));
return
folderDir
;
});
}
suite
(
'
ExtensionsTipsService Test
'
,
()
=>
{
let
workspaceService
:
IWorkspaceContextService
;
let
instantiationService
:
TestInstantiationService
;
let
testObject
:
IExtensionTipsService
;
let
parentResource
:
string
;
let
onModelAddedEvent
:
Emitter
<
IModel
>
;
const
model
:
IModel
=
EditorModel
.
createFromString
(
[
'
This is the first line
'
,
'
This is the second line
'
,
'
This is the third line
'
,
].
join
(
'
\n
'
),
undefined
,
undefined
,
URI
.
parse
(
'
far://testing/file.b
'
));
suiteSetup
(()
=>
{
onModelAddedEvent
=
new
Emitter
<
IModel
>
();
instantiationService
=
new
TestInstantiationService
();
instantiationService
.
stub
(
IModelService
,
<
IModelService
>
{
_serviceBrand
:
IModelService
,
getModel
():
any
{
return
model
;
},
createModel
():
any
{
throw
new
Error
();
},
updateModel
():
any
{
throw
new
Error
();
},
setMode
():
any
{
throw
new
Error
();
},
destroyModel
():
any
{
throw
new
Error
();
},
getModels
():
any
{
throw
new
Error
();
},
onModelAdded
:
onModelAddedEvent
.
event
,
onModelModeChanged
:
undefined
,
onModelRemoved
:
undefined
,
getCreationOptions
():
any
{
throw
new
Error
();
}
});
instantiationService
.
stub
(
ITelemetryService
,
NullTelemetryService
);
instantiationService
.
stub
(
IExtensionGalleryService
,
ExtensionGalleryService
);
instantiationService
.
stub
(
IConfigurationService
,
{
onDidUpdateConfiguration
:
()
=>
{
},
onDidChangeConfiguration
:
()
=>
{
},
getConfiguration
:
()
=>
({})
});
instantiationService
.
stub
(
IExtensionManagementService
,
ExtensionManagementService
);
});
setup
(()
=>
{
return
setUpFolderWorkspace
(
'
myFolder
'
).
then
(({
parentDir
,
folderDir
})
=>
{
parentResource
=
parentDir
;
const
myWorkspace
=
testWorkspace
(
URI
.
from
({
scheme
:
'
file
'
,
path
:
folderDir
}));
workspaceService
=
new
TestContextService
(
myWorkspace
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IFileService
,
new
FileService
(
workspaceService
,
new
TestTextResourceConfigurationService
(),
new
TestConfigurationService
(),
new
TestLifecycleService
(),
{
disableWatcher
:
true
}));
testObject
=
instantiationService
.
createInstance
(
ExtensionTipsService
);
});
});
teardown
((
done
)
=>
{
(
<
ExtensionTipsService
>
testObject
).
dispose
();
if
(
parentResource
)
{
extfs
.
del
(
parentResource
,
os
.
tmpdir
(),
()
=>
{
},
done
);
}
});
test
(
'
test workspace folder recommendations
'
,
()
=>
{
return
testObject
.
getWorkspaceRecommendations
().
then
(
recommendations
=>
{
assert
.
equal
(
recommendations
.
length
,
expectedWorkspaceRecommendations
.
length
);
recommendations
.
forEach
(
x
=>
assert
.
equal
(
expectedWorkspaceRecommendations
.
indexOf
(
x
)
>
-
1
,
true
));
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录