From 8f345dea8e227d8fba6e8f6bae0d7bc0db37e74c Mon Sep 17 00:00:00 2001 From: Rich Chiodo Date: Mon, 6 Jun 2022 16:14:14 -0700 Subject: [PATCH] Add unit test --- .../src/singlefolder-tests/notebook.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts index 33cad6edb97..5f46ef80a56 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts @@ -263,14 +263,17 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const editor = await vscode.window.showNotebookDocument(notebook); const notebookChangeEvent = asPromise(vscode.workspace.onDidChangeNotebookDocument); - const version = editor.document.version; - await editor.edit(editBuilder => { - editBuilder.replaceCells(1, 0, [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]); - editBuilder.replaceCellMetadata(0, { inputCollapsed: false }); - }); - + const version = editor.notebook.version; + const edit = new vscode.WorkspaceEdit(); + const cellEdit = vscode.NotebookEdit.replaceCells(new vscode.NotebookRange(1, 0), [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]); + const cellMetadataEdit = vscode.NotebookEdit.updateCellMetadata(0, { inputCollapsed: false }); + const metdataEdit = vscode.NotebookEdit.updateNotebookMetadata({ testMetadata: false }); + edit.set(notebook.uri, [cellEdit, cellMetadataEdit, metdataEdit]); + await vscode.workspace.applyEdit(edit); await notebookChangeEvent; - assert.strictEqual(version + 1, editor.document.version); + assert.strictEqual(version + 1, editor.notebook.version); + assert.strictEqual(cellMetadataEdit.newCellMetadata, editor.notebook.cellAt(0).metadata); + assert.strictEqual(metdataEdit.newNotebookMetadata, editor.notebook.metadata); }); test('edit API batch edits undo/redo', async function () {