Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
1bf1bc2c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1bf1bc2c
编写于
10月 04, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use async/await in tests
上级
3ad13abc
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
399 addition
and
467 deletion
+399
-467
src/vs/editor/contrib/suggest/test/suggest.test.ts
src/vs/editor/contrib/suggest/test/suggest.test.ts
+22
-26
src/vs/platform/configuration/test/node/configurationService.test.ts
...form/configuration/test/node/configurationService.test.ts
+105
-110
src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts
...ch/services/keybinding/test/windowsKeyboardMapper.test.ts
+11
-20
src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts
...es/preferences/test/common/keybindingsEditorModel.test.ts
+220
-261
src/vs/workbench/services/search/test/node/searchService.test.ts
...workbench/services/search/test/node/searchService.test.ts
+41
-50
未找到文件。
src/vs/editor/contrib/suggest/test/suggest.test.ts
浏览文件 @
1bf1bc2c
...
...
@@ -46,38 +46,34 @@ suite('Suggest', function () {
model
.
dispose
();
});
test
(
'
sort - snippet inline
'
,
function
()
{
return
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
inline
'
).
then
(
items
=>
{
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
fff
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
zzz
'
);
});
test
(
'
sort - snippet inline
'
,
async
function
()
{
const
items
=
await
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
inline
'
);
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
fff
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
zzz
'
);
});
test
(
'
sort - snippet top
'
,
function
()
{
return
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
top
'
).
then
(
items
=>
{
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
zzz
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
fff
'
);
});
test
(
'
sort - snippet top
'
,
async
function
()
{
const
items
=
await
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
top
'
);
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
zzz
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
fff
'
);
});
test
(
'
sort - snippet bottom
'
,
function
()
{
return
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
bottom
'
).
then
(
items
=>
{
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
fff
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
zzz
'
);
});
test
(
'
sort - snippet bottom
'
,
async
function
()
{
const
items
=
await
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
bottom
'
);
assert
.
equal
(
items
.
length
,
3
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
fff
'
);
assert
.
equal
(
items
[
1
].
suggestion
.
label
,
'
aaa
'
);
assert
.
equal
(
items
[
2
].
suggestion
.
label
,
'
zzz
'
);
});
test
(
'
sort - snippet none
'
,
function
()
{
return
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
none
'
).
then
(
items
=>
{
assert
.
equal
(
items
.
length
,
1
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
fff
'
);
});
test
(
'
sort - snippet none
'
,
async
function
()
{
const
items
=
await
provideSuggestionItems
(
model
,
new
Position
(
1
,
1
),
'
none
'
);
assert
.
equal
(
items
.
length
,
1
);
assert
.
equal
(
items
[
0
].
suggestion
.
label
,
'
fff
'
);
});
test
(
'
only from
'
,
function
()
{
...
...
src/vs/platform/configuration/test/node/configurationService.test.ts
浏览文件 @
1bf1bc2c
...
...
@@ -28,53 +28,57 @@ class SettingsTestEnvironmentService extends EnvironmentService {
suite
(
'
ConfigurationService - Node
'
,
()
=>
{
test
(
'
simple
'
,
()
=>
{
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
res
=>
{
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "bar" }
'
);
test
(
'
simple
'
,
async
()
=>
{
const
res
=
await
testFile
(
'
config
'
,
'
config.json
'
);
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "bar" }
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
const
config
=
service
.
getValue
<
{
foo
:
string
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
const
config
=
service
.
getValue
<
{
foo
:
string
;
}
>
();
service
.
dispose
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
service
.
dispose
();
return
res
.
cleanUp
();
});
return
res
.
cleanUp
();
});
test
(
'
config gets flattened
'
,
()
=>
{
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
res
=>
{
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "testworkbench.editor.tabs": true }
'
);
test
(
'
config gets flattened
'
,
async
()
=>
{
const
res
=
await
testFile
(
'
config
'
,
'
config.json
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
)
);
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "testworkbench.editor.tabs": true }
'
);
const
config
=
service
.
getValue
<
{
testworkbench
:
{
editor
:
{
tabs
:
boolean
}
}
}
>
();
assert
.
ok
(
config
);
assert
.
ok
(
config
.
testworkbench
);
assert
.
ok
(
config
.
testworkbench
.
editor
);
assert
.
equal
(
config
.
testworkbench
.
editor
.
tabs
,
true
);
service
.
dispose
();
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
const
config
=
service
.
getValue
<
{
testworkbench
:
{
editor
:
{
tabs
:
boolean
;
};
};
}
>
();
assert
.
ok
(
config
);
assert
.
ok
(
config
.
testworkbench
);
assert
.
ok
(
config
.
testworkbench
.
editor
);
assert
.
equal
(
config
.
testworkbench
.
editor
.
tabs
,
true
);
return
res
.
cleanUp
();
}
);
service
.
dispose
();
return
res
.
cleanUp
(
);
});
test
(
'
error case does not explode
'
,
()
=>
{
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
res
=>
{
fs
.
writeFileSync
(
res
.
testFile
,
'
,,,,
'
);
test
(
'
error case does not explode
'
,
async
()
=>
{
const
res
=
await
testFile
(
'
config
'
,
'
config.json
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
)
);
fs
.
writeFileSync
(
res
.
testFile
,
'
,,,,
'
);
const
config
=
service
.
getValue
<
{
foo
:
string
}
>
();
assert
.
ok
(
config
);
service
.
dispose
();
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
const
config
=
service
.
getValue
<
{
foo
:
string
;
}
>
();
assert
.
ok
(
config
);
return
res
.
cleanUp
();
}
);
service
.
dispose
();
return
res
.
cleanUp
(
);
});
test
(
'
missing file does not explode
'
,
()
=>
{
...
...
@@ -91,34 +95,36 @@ suite('ConfigurationService - Node', () => {
service
.
dispose
();
});
test
(
'
reloadConfiguration
'
,
()
=>
{
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
res
=>
{
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "bar" }
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
let
config
=
service
.
getValue
<
{
foo
:
string
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
test
(
'
reloadConfiguration
'
,
async
()
=>
{
const
res
=
await
testFile
(
'
config
'
,
'
config.json
'
);
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "changed
" }
'
);
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "bar
" }
'
);
// still outdated
config
=
service
.
getValue
<
{
foo
:
string
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
let
config
=
service
.
getValue
<
{
foo
:
string
;
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "foo": "changed" }
'
);
// force a reload to get latest
return
service
.
reloadConfiguration
().
then
(()
=>
{
config
=
service
.
getValue
<
{
foo
:
string
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
changed
'
);
// still outdated
config
=
service
.
getValue
<
{
foo
:
string
;
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
bar
'
);
service
.
dispose
();
// force a reload to get latest
await
service
.
reloadConfiguration
();
config
=
service
.
getValue
<
{
foo
:
string
;
}
>
();
assert
.
ok
(
config
);
assert
.
equal
(
config
.
foo
,
'
changed
'
);
return
res
.
cleanUp
();
});
});
service
.
dispose
();
return
res
.
cleanUp
();
});
test
(
'
model defaults
'
,
()
=>
{
...
...
@@ -148,7 +154,7 @@ suite('ConfigurationService - Node', () => {
assert
.
ok
(
setting
);
assert
.
equal
(
setting
.
configuration
.
service
.
testSetting
,
'
isSet
'
);
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
res
=>
{
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
async
res
=>
{
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "testworkbench.editor.tabs": true }
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
res
.
testFile
));
...
...
@@ -160,21 +166,17 @@ suite('ConfigurationService - Node', () => {
fs
.
writeFileSync
(
res
.
testFile
,
'
{ "configuration.service.testSetting": "isChanged" }
'
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
let
setting
=
service
.
getValue
<
ITestSetting
>
();
assert
.
ok
(
setting
);
assert
.
equal
(
setting
.
configuration
.
service
.
testSetting
,
'
isChanged
'
);
service
.
dispose
();
serviceWithoutFile
.
dispose
();
return
res
.
cleanUp
();
});
await
service
.
reloadConfiguration
();
let
setting_1
=
service
.
getValue
<
ITestSetting
>
();
assert
.
ok
(
setting_1
);
assert
.
equal
(
setting_1
.
configuration
.
service
.
testSetting
,
'
isChanged
'
);
service
.
dispose
();
serviceWithoutFile
.
dispose
();
return
res
.
cleanUp
();
});
});
test
(
'
lookup
'
,
()
=>
{
test
(
'
lookup
'
,
async
()
=>
{
const
configurationRegistry
=
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
);
configurationRegistry
.
registerConfiguration
({
'
id
'
:
'
_test
'
,
...
...
@@ -187,35 +189,31 @@ suite('ConfigurationService - Node', () => {
}
});
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
r
=>
{
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
r
.
testFile
));
let
res
=
service
.
inspect
(
'
something.missing
'
);
assert
.
strictEqual
(
res
.
value
,
void
0
);
assert
.
strictEqual
(
res
.
default
,
void
0
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
res
=
service
.
inspect
(
'
lookup.service.testSetting
'
);
assert
.
strictEqual
(
res
.
default
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
value
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
const
r
=
await
testFile
(
'
config
'
,
'
config.json
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
r
.
testFile
));
let
res
=
service
.
inspect
(
'
something.missing
'
);
assert
.
strictEqual
(
res
.
value
,
void
0
);
assert
.
strictEqual
(
res
.
default
,
void
0
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
fs
.
writeFileSync
(
r
.
testFile
,
'
{ "lookup.service.testSetting": "bar" }
'
);
res
=
service
.
inspect
(
'
lookup.service.testSetting
'
);
assert
.
strictEqual
(
res
.
default
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
value
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
res
=
service
.
inspect
(
'
lookup.service.testSetting
'
);
assert
.
strictEqual
(
res
.
default
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
user
,
'
bar
'
);
assert
.
strictEqual
(
res
.
value
,
'
bar
'
);
fs
.
writeFileSync
(
r
.
testFile
,
'
{ "lookup.service.testSetting": "bar" }
'
);
service
.
dispose
();
await
service
.
reloadConfiguration
();
res
=
service
.
inspect
(
'
lookup.service.testSetting
'
);
assert
.
strictEqual
(
res
.
default
,
'
isSet
'
);
assert
.
strictEqual
(
res
.
user
,
'
bar
'
);
assert
.
strictEqual
(
res
.
value
,
'
bar
'
);
return
r
.
cleanUp
();
});
});
service
.
dispose
();
return
r
.
cleanUp
();
});
test
(
'
lookup with null
'
,
()
=>
{
test
(
'
lookup with null
'
,
async
()
=>
{
const
configurationRegistry
=
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
);
configurationRegistry
.
registerConfiguration
({
'
id
'
:
'
_testNull
'
,
...
...
@@ -227,26 +225,23 @@ suite('ConfigurationService - Node', () => {
}
});
return
testFile
(
'
config
'
,
'
config.json
'
).
then
(
r
=>
{
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
r
.
testFile
));
let
res
=
service
.
inspect
(
'
lookup.service.testNullSetting
'
);
assert
.
strictEqual
(
res
.
default
,
null
);
assert
.
strictEqual
(
res
.
value
,
null
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
const
r
=
await
testFile
(
'
config
'
,
'
config.json
'
);
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
r
.
testFile
));
let
res
=
service
.
inspect
(
'
lookup.service.testNullSetting
'
);
assert
.
strictEqual
(
res
.
default
,
null
);
assert
.
strictEqual
(
res
.
value
,
null
);
assert
.
strictEqual
(
res
.
user
,
void
0
);
fs
.
writeFileSync
(
r
.
testFile
,
'
{ "lookup.service.testNullSetting": null }
'
);
fs
.
writeFileSync
(
r
.
testFile
,
'
{ "lookup.service.testNullSetting": null }
'
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
res
=
service
.
inspect
(
'
lookup.service.testNullSetting
'
);
assert
.
strictEqual
(
res
.
default
,
null
);
assert
.
strictEqual
(
res
.
value
,
null
);
assert
.
strictEqual
(
res
.
user
,
null
);
await
service
.
reloadConfiguration
();
service
.
dispose
();
res
=
service
.
inspect
(
'
lookup.service.testNullSetting
'
);
assert
.
strictEqual
(
res
.
default
,
null
);
assert
.
strictEqual
(
res
.
value
,
null
);
assert
.
strictEqual
(
res
.
user
,
null
);
return
r
.
cleanUp
();
});
});
service
.
dispose
();
return
r
.
cleanUp
();
});
});
src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts
浏览文件 @
1bf1bc2c
...
...
@@ -12,10 +12,9 @@ import { ScanCodeBinding, ScanCode } from 'vs/base/common/scanCode';
const
WRITE_FILE_IF_DIFFERENT
=
false
;
function
createKeyboardMapper
(
isUSStandard
:
boolean
,
file
:
string
):
TPromise
<
WindowsKeyboardMapper
>
{
return
readRawMapping
<
IWindowsKeyboardMapping
>
(
file
).
then
((
rawMappings
)
=>
{
return
new
WindowsKeyboardMapper
(
isUSStandard
,
rawMappings
);
});
async
function
createKeyboardMapper
(
isUSStandard
:
boolean
,
file
:
string
):
TPromise
<
WindowsKeyboardMapper
>
{
const
rawMappings
=
await
readRawMapping
<
IWindowsKeyboardMapping
>
(
file
);
return
new
WindowsKeyboardMapper
(
isUSStandard
,
rawMappings
);
}
function
_assertResolveKeybinding
(
mapper
:
WindowsKeyboardMapper
,
k
:
number
,
expected
:
IResolvedKeybinding
[]):
void
{
...
...
@@ -26,10 +25,8 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
(()
=>
{
return
createKeyboardMapper
(
false
,
'
win_de_ch
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
});
suiteSetup
(
async
()
=>
{
mapper
=
await
createKeyboardMapper
(
false
,
'
win_de_ch
'
);
});
test
(
'
mapping
'
,
()
=>
{
...
...
@@ -318,10 +315,8 @@ suite('keyboardMapper - WINDOWS en_us', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
(()
=>
{
return
createKeyboardMapper
(
true
,
'
win_en_us
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
});
suiteSetup
(
async
()
=>
{
mapper
=
await
createKeyboardMapper
(
true
,
'
win_en_us
'
);
});
test
(
'
mapping
'
,
()
=>
{
...
...
@@ -406,10 +401,8 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
(()
=>
{
return
createKeyboardMapper
(
false
,
'
win_por_ptb
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
});
suiteSetup
(
async
()
=>
{
mapper
=
await
createKeyboardMapper
(
false
,
'
win_por_ptb
'
);
});
test
(
'
mapping
'
,
()
=>
{
...
...
@@ -467,10 +460,8 @@ suite('keyboardMapper - WINDOWS ru', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
(()
=>
{
return
createKeyboardMapper
(
false
,
'
win_ru
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
});
suiteSetup
(
async
()
=>
{
mapper
=
await
createKeyboardMapper
(
false
,
'
win_ru
'
);
});
test
(
'
mapping
'
,
()
=>
{
...
...
src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts
浏览文件 @
1bf1bc2c
此差异已折叠。
点击以展开。
src/vs/workbench/services/search/test/node/searchService.test.ts
浏览文件 @
1bf1bc2c
...
...
@@ -91,7 +91,7 @@ suite('SearchService', () => {
path
:
path
.
normalize
(
'
/some/where
'
)
};
test
(
'
Individual results
'
,
function
()
{
test
(
'
Individual results
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
let
i
=
5
;
const
Engine
=
TestSearchEngine
.
bind
(
null
,
()
=>
i
--
&&
rawMatch
);
...
...
@@ -107,11 +107,11 @@ suite('SearchService', () => {
}
};
return
service
.
doFileSearch
(
Engine
,
rawSearch
,
cb
)
.
then
(()
=>
assert
.
strictEqual
(
results
,
5
)
);
await
service
.
doFileSearch
(
Engine
,
rawSearch
,
cb
);
return
assert
.
strictEqual
(
results
,
5
);
});
test
(
'
Batch results
'
,
function
()
{
test
(
'
Batch results
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
let
i
=
25
;
const
Engine
=
TestSearchEngine
.
bind
(
null
,
()
=>
i
--
&&
rawMatch
);
...
...
@@ -129,12 +129,11 @@ suite('SearchService', () => {
}
};
return
service
.
doFileSearch
(
Engine
,
rawSearch
,
cb
,
undefined
,
10
).
then
(()
=>
{
assert
.
deepStrictEqual
(
results
,
[
10
,
10
,
5
]);
});
await
service
.
doFileSearch
(
Engine
,
rawSearch
,
cb
,
undefined
,
10
);
assert
.
deepStrictEqual
(
results
,
[
10
,
10
,
5
]);
});
test
(
'
Collect batched results
'
,
function
()
{
test
(
'
Collect batched results
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
const
uriPath
=
'
/some/where
'
;
let
i
=
25
;
...
...
@@ -163,14 +162,12 @@ suite('SearchService', () => {
progressResults
.
push
(
match
);
};
return
DiskSearch
.
collectResultsFromEvent
(
fileSearch
(
rawSearch
,
10
),
onProgress
)
.
then
(
result
=>
{
assert
.
strictEqual
(
result
.
results
.
length
,
25
,
'
Result
'
);
assert
.
strictEqual
(
progressResults
.
length
,
25
,
'
Progress
'
);
});
const
result_2
=
await
DiskSearch
.
collectResultsFromEvent
(
fileSearch
(
rawSearch
,
10
),
onProgress
);
assert
.
strictEqual
(
result_2
.
results
.
length
,
25
,
'
Result
'
);
assert
.
strictEqual
(
progressResults
.
length
,
25
,
'
Progress
'
);
});
test
(
'
Multi-root with include pattern and maxResults
'
,
function
()
{
test
(
'
Multi-root with include pattern and maxResults
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
const
service
=
new
RawSearchService
();
...
...
@@ -183,13 +180,11 @@ suite('SearchService', () => {
},
};
return
DiskSearch
.
collectResultsFromEvent
(
service
.
fileSearch
(
query
))
.
then
(
result
=>
{
assert
.
strictEqual
(
result
.
results
.
length
,
1
,
'
Result
'
);
});
const
result
=
await
DiskSearch
.
collectResultsFromEvent
(
service
.
fileSearch
(
query
));
assert
.
strictEqual
(
result
.
results
.
length
,
1
,
'
Result
'
);
});
test
(
'
Multi-root with include pattern and exists
'
,
function
()
{
test
(
'
Multi-root with include pattern and exists
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
const
service
=
new
RawSearchService
();
...
...
@@ -202,14 +197,12 @@ suite('SearchService', () => {
},
};
return
DiskSearch
.
collectResultsFromEvent
(
service
.
fileSearch
(
query
))
.
then
(
result
=>
{
assert
.
strictEqual
(
result
.
results
.
length
,
0
,
'
Result
'
);
assert
.
ok
(
result
.
limitHit
);
});
const
result
=
await
DiskSearch
.
collectResultsFromEvent
(
service
.
fileSearch
(
query
));
assert
.
strictEqual
(
result
.
results
.
length
,
0
,
'
Result
'
);
assert
.
ok
(
result
.
limitHit
);
});
test
(
'
Sorted results
'
,
function
()
{
test
(
'
Sorted results
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
const
paths
=
[
'
bab
'
,
'
bbc
'
,
'
abb
'
];
const
matches
:
IRawFileMatch
[]
=
paths
.
map
(
relativePath
=>
({
...
...
@@ -230,18 +223,17 @@ suite('SearchService', () => {
}
};
return
service
.
doFileSearch
(
Engine
,
{
await
service
.
doFileSearch
(
Engine
,
{
folderQueries
:
TEST_FOLDER_QUERIES
,
filePattern
:
'
bb
'
,
sortByScore
:
true
,
maxResults
:
2
},
cb
,
undefined
,
1
).
then
(()
=>
{
assert
.
notStrictEqual
(
typeof
TestSearchEngine
.
last
.
config
.
maxResults
,
'
number
'
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bbc
'
),
path
.
normalize
(
'
/some/where/bab
'
)]);
});
},
cb
,
undefined
,
1
);
assert
.
notStrictEqual
(
typeof
TestSearchEngine
.
last
.
config
.
maxResults
,
'
number
'
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bbc
'
),
path
.
normalize
(
'
/some/where/bab
'
)]);
});
test
(
'
Sorted result batches
'
,
function
()
{
test
(
'
Sorted result batches
'
,
async
function
()
{
this
.
timeout
(
testTimeout
);
let
i
=
25
;
const
Engine
=
TestSearchEngine
.
bind
(
null
,
()
=>
i
--
&&
rawMatch
);
...
...
@@ -258,15 +250,13 @@ suite('SearchService', () => {
assert
.
fail
(
JSON
.
stringify
(
value
));
}
};
return
service
.
doFileSearch
(
Engine
,
{
await
service
.
doFileSearch
(
Engine
,
{
folderQueries
:
TEST_FOLDER_QUERIES
,
filePattern
:
'
a
'
,
sortByScore
:
true
,
maxResults
:
23
},
cb
,
undefined
,
10
)
.
then
(()
=>
{
assert
.
deepStrictEqual
(
results
,
[
10
,
10
,
3
]);
});
},
cb
,
undefined
,
10
);
assert
.
deepStrictEqual
(
results
,
[
10
,
10
,
3
]);
});
test
(
'
Cached results
'
,
function
()
{
...
...
@@ -297,7 +287,7 @@ suite('SearchService', () => {
},
cb
,
undefined
,
-
1
).
then
(
complete
=>
{
assert
.
strictEqual
((
<
IFileSearchStats
>
complete
.
stats
).
fromCache
,
false
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bcb
'
),
path
.
normalize
(
'
/some/where/bbc
'
),
path
.
normalize
(
'
/some/where/aab
'
)]);
}).
then
(()
=>
{
}).
then
(
async
()
=>
{
const
results
=
[];
const
cb
=
value
=>
{
if
(
Array
.
isArray
(
value
))
{
...
...
@@ -306,18 +296,20 @@ suite('SearchService', () => {
assert
.
fail
(
JSON
.
stringify
(
value
));
}
};
return
service
.
doFileSearch
(
Engine
,
{
folderQueries
:
TEST_FOLDER_QUERIES
,
filePattern
:
'
bc
'
,
sortByScore
:
true
,
cacheKey
:
'
x
'
},
cb
,
undefined
,
-
1
).
then
(
complete
=>
{
try
{
const
complete
=
await
service
.
doFileSearch
(
Engine
,
{
folderQueries
:
TEST_FOLDER_QUERIES
,
filePattern
:
'
bc
'
,
sortByScore
:
true
,
cacheKey
:
'
x
'
},
cb
,
undefined
,
-
1
);
assert
.
ok
((
<
IFileSearchStats
>
complete
.
stats
).
fromCache
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bcb
'
),
path
.
normalize
(
'
/some/where/bbc
'
)]);
},
null
);
}
catch
(
e
)
{
}
}).
then
(()
=>
{
return
service
.
clearCache
(
'
x
'
);
}).
then
(()
=>
{
}).
then
(
async
()
=>
{
matches
.
push
({
base
:
path
.
normalize
(
'
/some/where
'
),
relativePath
:
'
bc
'
,
...
...
@@ -332,15 +324,14 @@ suite('SearchService', () => {
assert
.
fail
(
JSON
.
stringify
(
value
));
}
};
return
service
.
doFileSearch
(
Engine
,
{
const
complete
=
await
service
.
doFileSearch
(
Engine
,
{
folderQueries
:
TEST_FOLDER_QUERIES
,
filePattern
:
'
bc
'
,
sortByScore
:
true
,
cacheKey
:
'
x
'
},
cb
,
undefined
,
-
1
).
then
(
complete
=>
{
assert
.
strictEqual
((
<
IFileSearchStats
>
complete
.
stats
).
fromCache
,
false
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bc
'
)]);
});
},
cb
,
undefined
,
-
1
);
assert
.
strictEqual
((
<
IFileSearchStats
>
complete
.
stats
).
fromCache
,
false
);
assert
.
deepStrictEqual
(
results
,
[
path
.
normalize
(
'
/some/where/bc
'
)]);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录