mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 16:18:58 +01:00
add NotebookDocument.save().
This commit is contained in:
@@ -293,4 +293,37 @@ suite('Notebook Document', function () {
|
||||
assert.deepStrictEqual(data.cells[0].outputs, [thirdOutput]);
|
||||
}
|
||||
});
|
||||
|
||||
test('document save API', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const notebook = await vscode.notebook.openNotebookDocument(uri);
|
||||
|
||||
assert.strictEqual(notebook.uri.toString(), uri.toString());
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
assert.strictEqual(notebook.isUntitled, false);
|
||||
assert.strictEqual(notebook.cells.length, 1);
|
||||
assert.strictEqual(notebook.viewType, 'notebook.nbdtest');
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCells(notebook.uri, 0, 0, [{
|
||||
cellKind: vscode.NotebookCellKind.Markdown,
|
||||
language: 'markdown',
|
||||
metadata: undefined,
|
||||
outputs: [],
|
||||
source: 'new_markdown'
|
||||
}, {
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
language: 'fooLang',
|
||||
metadata: undefined,
|
||||
outputs: [],
|
||||
source: 'new_code'
|
||||
}]);
|
||||
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, true);
|
||||
assert.strictEqual(notebook.isDirty, true);
|
||||
|
||||
await notebook.save();
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user