Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7fdda46e
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,发现更多精彩内容 >>
提交
7fdda46e
编写于
9月 10, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some integration tests for notebook editing,
https://github.com/microsoft/vscode/issues/105283
上级
6e022766
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
132 addition
and
4 deletion
+132
-4
extensions/vscode-notebook-tests/src/notebook.test.ts
extensions/vscode-notebook-tests/src/notebook.test.ts
+132
-4
未找到文件。
extensions/vscode-notebook-tests/src/notebook.test.ts
浏览文件 @
7fdda46e
...
...
@@ -423,7 +423,7 @@ suite('Notebook API tests', () => {
await
vscode
.
commands
.
executeCommand
(
'
vscode.openWith
'
,
resource
,
'
notebookCoreTest
'
);
await
vscode
.
notebook
.
activeNotebookEditor
!
.
edit
(
editBuilder
=>
{
editBuilder
.
replaceOutput
(
0
,
[{
outputKind
:
vscode
.
CellOutputKind
.
Rich
,
data
:
{
foo
:
'
bar
'
}
}]);
editBuilder
.
replace
Cell
Output
(
0
,
[{
outputKind
:
vscode
.
CellOutputKind
.
Rich
,
data
:
{
foo
:
'
bar
'
}
}]);
});
const
document
=
vscode
.
notebook
.
activeNotebookEditor
?.
document
!
;
...
...
@@ -442,7 +442,7 @@ suite('Notebook API tests', () => {
const
outputChangeEvent
=
getEventOncePromise
<
vscode
.
NotebookCellOutputsChangeEvent
>
(
vscode
.
notebook
.
onDidChangeCellOutputs
);
await
vscode
.
notebook
.
activeNotebookEditor
!
.
edit
(
editBuilder
=>
{
editBuilder
.
replaceOutput
(
0
,
[{
outputKind
:
vscode
.
CellOutputKind
.
Rich
,
data
:
{
foo
:
'
bar
'
}
}]);
editBuilder
.
replace
Cell
Output
(
0
,
[{
outputKind
:
vscode
.
CellOutputKind
.
Rich
,
data
:
{
foo
:
'
bar
'
}
}]);
});
const
value
=
await
outputChangeEvent
;
...
...
@@ -462,7 +462,7 @@ suite('Notebook API tests', () => {
await
vscode
.
commands
.
executeCommand
(
'
vscode.openWith
'
,
resource
,
'
notebookCoreTest
'
);
await
vscode
.
notebook
.
activeNotebookEditor
!
.
edit
(
editBuilder
=>
{
editBuilder
.
replaceMetadata
(
0
,
{
inputCollapsed
:
true
,
executionOrder
:
17
});
editBuilder
.
replace
Cell
Metadata
(
0
,
{
inputCollapsed
:
true
,
executionOrder
:
17
});
});
const
document
=
vscode
.
notebook
.
activeNotebookEditor
?.
document
!
;
...
...
@@ -483,7 +483,7 @@ suite('Notebook API tests', () => {
const
event
=
getEventOncePromise
<
vscode
.
NotebookCellMetadataChangeEvent
>
(
vscode
.
notebook
.
onDidChangeCellMetadata
);
await
vscode
.
notebook
.
activeNotebookEditor
!
.
edit
(
editBuilder
=>
{
editBuilder
.
replaceMetadata
(
0
,
{
inputCollapsed
:
true
,
executionOrder
:
17
});
editBuilder
.
replace
Cell
Metadata
(
0
,
{
inputCollapsed
:
true
,
executionOrder
:
17
});
});
const
data
=
await
event
;
...
...
@@ -495,6 +495,134 @@ suite('Notebook API tests', () => {
await
saveFileAndCloseAll
(
resource
);
});
test
(
'
workspace edit API (replaceCells)
'
,
async
function
()
{
assertInitalState
();
const
resource
=
await
createRandomFile
(
''
,
undefined
,
'
first
'
,
'
.vsctestnb
'
);
await
vscode
.
commands
.
executeCommand
(
'
vscode.openWith
'
,
resource
,
'
notebookCoreTest
'
);
const
{
document
}
=
vscode
.
notebook
.
activeNotebookEditor
!
;
assert
.
strictEqual
(
document
.
cells
.
length
,
1
);
// inserting two new cells
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replaceCells
(
document
.
uri
,
0
,
0
,
[{
cellKind
:
vscode
.
CellKind
.
Markdown
,
language
:
'
markdown
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new_markdown
'
},
{
cellKind
:
vscode
.
CellKind
.
Code
,
language
:
'
fooLang
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new_code
'
}]);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
assert
.
strictEqual
(
success
,
true
);
}
assert
.
strictEqual
(
document
.
cells
.
length
,
3
);
assert
.
strictEqual
(
document
.
cells
[
0
].
document
.
getText
(),
'
new_markdown
'
);
assert
.
strictEqual
(
document
.
cells
[
1
].
document
.
getText
(),
'
new_code
'
);
// deleting cell 1 and 3
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replaceCells
(
document
.
uri
,
0
,
1
,
[]);
edit
.
replaceCells
(
document
.
uri
,
2
,
3
,
[]);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
assert
.
strictEqual
(
success
,
true
);
}
assert
.
strictEqual
(
document
.
cells
.
length
,
1
);
assert
.
strictEqual
(
document
.
cells
[
0
].
document
.
getText
(),
'
new_code
'
);
// replacing all cells
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replaceCells
(
document
.
uri
,
0
,
1
,
[{
cellKind
:
vscode
.
CellKind
.
Markdown
,
language
:
'
markdown
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new2_markdown
'
},
{
cellKind
:
vscode
.
CellKind
.
Code
,
language
:
'
fooLang
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new2_code
'
}]);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
assert
.
strictEqual
(
success
,
true
);
}
assert
.
strictEqual
(
document
.
cells
.
length
,
2
);
assert
.
strictEqual
(
document
.
cells
[
0
].
document
.
getText
(),
'
new2_markdown
'
);
assert
.
strictEqual
(
document
.
cells
[
1
].
document
.
getText
(),
'
new2_code
'
);
// remove all cells
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replaceCells
(
document
.
uri
,
0
,
document
.
cells
.
length
,
[]);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
assert
.
strictEqual
(
success
,
true
);
}
assert
.
strictEqual
(
document
.
cells
.
length
,
0
);
await
saveFileAndCloseAll
(
resource
);
});
test
(
'
workspace edit API (replaceCells, event)
'
,
async
function
()
{
assertInitalState
();
const
resource
=
await
createRandomFile
(
''
,
undefined
,
'
first
'
,
'
.vsctestnb
'
);
await
vscode
.
commands
.
executeCommand
(
'
vscode.openWith
'
,
resource
,
'
notebookCoreTest
'
);
const
{
document
}
=
vscode
.
notebook
.
activeNotebookEditor
!
;
assert
.
strictEqual
(
document
.
cells
.
length
,
1
);
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replaceCells
(
document
.
uri
,
0
,
0
,
[{
cellKind
:
vscode
.
CellKind
.
Markdown
,
language
:
'
markdown
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new_markdown
'
},
{
cellKind
:
vscode
.
CellKind
.
Code
,
language
:
'
fooLang
'
,
metadata
:
undefined
,
outputs
:
[],
source
:
'
new_code
'
}]);
const
event
=
getEventOncePromise
<
vscode
.
NotebookCellsChangeEvent
>
(
vscode
.
notebook
.
onDidChangeNotebookCells
);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
assert
.
strictEqual
(
success
,
true
);
const
data
=
await
event
;
// check document
assert
.
strictEqual
(
document
.
cells
.
length
,
3
);
assert
.
strictEqual
(
document
.
cells
[
0
].
document
.
getText
(),
'
new_markdown
'
);
assert
.
strictEqual
(
document
.
cells
[
1
].
document
.
getText
(),
'
new_code
'
);
// check event data
assert
.
strictEqual
(
data
.
document
===
document
,
true
);
assert
.
strictEqual
(
data
.
changes
.
length
,
1
);
assert
.
strictEqual
(
data
.
changes
[
0
].
deletedCount
,
0
);
assert
.
strictEqual
(
data
.
changes
[
0
].
deletedItems
.
length
,
0
);
assert
.
strictEqual
(
data
.
changes
[
0
].
items
.
length
,
2
);
assert
.
strictEqual
(
data
.
changes
[
0
].
items
[
0
],
document
.
cells
[
0
]);
assert
.
strictEqual
(
data
.
changes
[
0
].
items
[
1
],
document
.
cells
[
1
]);
await
saveFileAndCloseAll
(
resource
);
});
test
(
'
initialzation should not emit cell change events.
'
,
async
function
()
{
assertInitalState
();
const
resource
=
await
createRandomFile
(
''
,
undefined
,
'
first
'
,
'
.vsctestnb
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录