Merge branch 'notebook/dev' into main

This commit is contained in:
rebornix
2021-05-19 14:12:17 -07:00
35 changed files with 843 additions and 497 deletions

View File

@@ -47,10 +47,6 @@ suite('Notebook Document', function () {
await utils.closeAllEditors();
utils.disposeAll(disposables);
disposables.length = 0;
for (let doc of vscode.notebook.notebookDocuments) {
assert.strictEqual(doc.isDirty, false, doc.uri.toString());
}
});
suiteSetup(function () {
@@ -140,6 +136,30 @@ suite('Notebook Document', function () {
await p;
});
test('open untitled notebook', async function () {
const nb = await vscode.notebook.openNotebookDocument('notebook.nbdserializer');
assert.strictEqual(nb.isUntitled, true);
assert.strictEqual(nb.isClosed, false);
assert.strictEqual(nb.uri.scheme, 'untitled');
// assert.strictEqual(nb.cellCount, 0); // NotebookSerializer ALWAYS returns something here
});
test('open untitled with data', async function () {
const nb = await vscode.notebook.openNotebookDocument(
'notebook.nbdserializer',
new vscode.NotebookData([
new vscode.NotebookCellData(vscode.NotebookCellKind.Code, 'console.log()', 'javascript'),
new vscode.NotebookCellData(vscode.NotebookCellKind.Markup, 'Hey', 'markdown'),
])
);
assert.strictEqual(nb.isUntitled, true);
assert.strictEqual(nb.isClosed, false);
assert.strictEqual(nb.uri.scheme, 'untitled');
assert.strictEqual(nb.cellCount, 2);
assert.strictEqual(nb.cellAt(0).kind, vscode.NotebookCellKind.Code);
assert.strictEqual(nb.cellAt(1).kind, vscode.NotebookCellKind.Markup);
});
test('workspace edit API (replaceCells)', async function () {
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');

View File

@@ -104,8 +104,8 @@ suite('Notebook API tests', function () {
suiteSetup(function () {
suiteDisposables.push(vscode.notebook.registerNotebookContentProvider('notebookCoreTest', {
openNotebook: async (_resource: vscode.Uri): Promise<vscode.NotebookData> => {
if (/.*empty\-.*\.vsctestnb$/.test(_resource.path)) {
openNotebook: async (resource: vscode.Uri): Promise<vscode.NotebookData> => {
if (/.*empty\-.*\.vsctestnb$/.test(resource.path)) {
return {
metadata: new vscode.NotebookDocumentMetadata(),
cells: []