mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Unit test for #142466
This commit is contained in:
parent
666ae990e6
commit
25e06c623e
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { DeferredPromise } from 'vs/base/common/async';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
@ -17,7 +18,7 @@ import { NotebookExecutionStateService } from 'vs/workbench/contrib/notebook/bro
|
|||
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl';
|
||||
import { NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl';
|
||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||
import { CellEditType, CellKind, IOutputDto, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellEditType, CellKind, CellUri, IOutputDto, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { INotebookExecutionService } from 'vs/workbench/contrib/notebook/common/notebookExecutionService';
|
||||
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
||||
import { INotebookKernel, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
|
||||
|
@ -116,6 +117,38 @@ suite('NotebookExecutionStateService', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// #142466
|
||||
test('getCellExecution and onDidChangeCellExecution', async function () {
|
||||
return withTestNotebook([], async viewModel => {
|
||||
testNotebookModel = viewModel.notebookDocument;
|
||||
|
||||
const kernel = new TestNotebookKernel();
|
||||
kernelService.registerKernel(kernel);
|
||||
kernelService.selectKernelForNotebook(kernel, viewModel.notebookDocument);
|
||||
|
||||
const executionStateService: INotebookExecutionStateService = instantiationService.get(INotebookExecutionStateService);
|
||||
const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
|
||||
|
||||
const deferred = new DeferredPromise<void>();
|
||||
disposables.add(executionStateService.onDidChangeCellExecution(e => {
|
||||
const cellUri = CellUri.generate(e.notebook, e.cellHandle);
|
||||
const exe = executionStateService.getCellExecution(cellUri);
|
||||
assert.ok(exe);
|
||||
assert.strictEqual(e.notebook.toString(), exe.notebook.toString());
|
||||
assert.strictEqual(e.cellHandle, exe.cellHandle);
|
||||
|
||||
assert.strictEqual(exe.notebook.toString(), e.changed?.notebook.toString());
|
||||
assert.strictEqual(exe.cellHandle, e.changed?.cellHandle);
|
||||
|
||||
deferred.complete();
|
||||
}));
|
||||
|
||||
executionStateService.createCellExecution(kernel.id, viewModel.uri, cell.handle);
|
||||
|
||||
return deferred.p;
|
||||
});
|
||||
});
|
||||
|
||||
test('force-cancel works', async function () {
|
||||
return withTestNotebook([], async viewModel => {
|
||||
testNotebookModel = viewModel.notebookDocument;
|
||||
|
|
Loading…
Reference in a new issue