diff options
author | Rob Lourens <roblourens@gmail.com> | 2022-11-11 08:43:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 08:43:43 +0300 |
commit | e31078d3038e740711d52211f051a7084f98b90c (patch) | |
tree | 3d286be0a3f38f7ba667f4f00a223ba10e1039c4 | |
parent | 9f2be311ff72dc348c794d6d47aeb8cda881ebf4 (diff) |
Fix bad method calls in notebook execution test, via #164297 (#166078)
-rw-r--r-- | src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts b/src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts index 230b0813ead..ccec9075613 100644 --- a/src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts +++ b/src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts @@ -12,9 +12,9 @@ import { mock } from 'vs/base/test/common/mock'; import { assertThrowsAsync } from 'vs/base/test/common/utils'; import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'; import { IMenu, IMenuService } from 'vs/platform/actions/common/actions'; +import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; -import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; import { insertCellAtIndex } from 'vs/workbench/contrib/notebook/browser/controller/cellOperations'; import { NotebookExecutionService } from 'vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl'; import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl'; @@ -29,6 +29,7 @@ import { setupInstantiationService, withTestNotebook as _withTestNotebook } from suite('NotebookExecutionService', () => { let instantiationService: TestInstantiationService; + let contextKeyService: IContextKeyService; let kernelService: INotebookKernelService; let disposables: DisposableStore; @@ -56,6 +57,7 @@ suite('NotebookExecutionService', () => { kernelService = instantiationService.createInstance(NotebookKernelService); instantiationService.set(INotebookKernelService, kernelService); + contextKeyService = instantiationService.get(IContextKeyService); }); @@ -77,23 +79,23 @@ suite('NotebookExecutionService', () => { test('cell is not runnable when no kernel is selected', async () => { await withTestNotebook( [], - async (viewModel) => { + async (viewModel, textModel) => { const executionService = instantiationService.createInstance(NotebookExecutionService); const cell = insertCellAtIndex(viewModel, 1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true); - await assertThrowsAsync(async () => await executionService.executeNotebookCell(cell)); + await assertThrowsAsync(async () => await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService)); }); }); test('cell is not runnable when kernel does not support the language', async () => { await withTestNotebook( [], - async (viewModel) => { + async (viewModel, textModel) => { kernelService.registerKernel(new TestNotebookKernel({ languages: ['testlang'] })); const executionService = instantiationService.createInstance(NotebookExecutionService); const cell = insertCellAtIndex(viewModel, 1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true); - await assertThrowsAsync(async () => await executionService.executeNotebookCell(cell)); + await assertThrowsAsync(async () => await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService)); }); }); @@ -101,7 +103,7 @@ suite('NotebookExecutionService', () => { test('cell is runnable when kernel does support the language', async () => { await withTestNotebook( [], - async (viewModel) => { + async (viewModel, textModel) => { const kernel = new TestNotebookKernel({ languages: ['javascript'] }); kernelService.registerKernel(kernel); const executionService = instantiationService.createInstance(NotebookExecutionService); @@ -109,7 +111,7 @@ suite('NotebookExecutionService', () => { kernel.executeNotebookCellsRequest = executeSpy; const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true); - await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService()); + await executionService.executeNotebookCells(viewModel.notebookDocument, [cell.model], contextKeyService); assert.strictEqual(executeSpy.calledOnce, true); }); }); @@ -117,8 +119,8 @@ suite('NotebookExecutionService', () => { test('select kernel when running cell', async function () { // https://github.com/microsoft/vscode/issues/121904 - return withTestNotebook([], async viewModel => { - assert.strictEqual(kernelService.getMatchingKernel(viewModel.notebookDocument).all.length, 0); + return withTestNotebook([], async (viewModel, textModel) => { + assert.strictEqual(kernelService.getMatchingKernel(textModel).all.length, 0); let didExecute = false; const kernel = new class extends TestNotebookKernel { @@ -140,7 +142,7 @@ suite('NotebookExecutionService', () => { kernelService.onDidChangeSelectedNotebooks(e => event = e); const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true); - await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService()); + await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService); assert.strictEqual(didExecute, true); assert.ok(event !== undefined); @@ -151,7 +153,7 @@ suite('NotebookExecutionService', () => { test('Completes unconfirmed executions', async function () { - return withTestNotebook([], async viewModel => { + return withTestNotebook([], async (viewModel, textModel) => { let didExecute = false; const kernel = new class extends TestNotebookKernel { constructor() { @@ -170,7 +172,7 @@ suite('NotebookExecutionService', () => { const exeStateService = instantiationService.get(INotebookExecutionStateService); const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true); - await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService()); + await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService); assert.strictEqual(didExecute, true); assert.strictEqual(exeStateService.getCellExecution(cell.uri), undefined); |