New tests for NotebookServiceImpl module (#11250)

* Working tests Upto 97.5% coverage

* pr feedback

* pr feedback

* pr feedback and test bug fixes + 1 new test

* revert debug change
This commit is contained in:
Arvind Ranasaria
2020-07-14 23:08:58 -07:00
committed by GitHub
parent dc7e6f59bd
commit f8f64340f6
7 changed files with 604 additions and 105 deletions

View File

@@ -6,6 +6,7 @@
import { QueryTextEditor } from 'sql/workbench/browser/modelComponents/queryTextEditor';
import * as stubs from 'sql/workbench/contrib/notebook/test/stubs';
import { INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { INotebookParams } from 'sql/workbench/services/notebook/browser/notebookService';
import * as dom from 'vs/base/browser/dom';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -18,20 +19,21 @@ import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServic
// Leave both undefined when you want the underlying object(s) to have an undefined editor.
export class NotebookEditorStub extends stubs.NotebookEditorStub {
cellEditors: CellEditorProviderStub[];
private _model: INotebookModel | undefined;
model: INotebookModel | undefined;
get model(): INotebookModel | undefined {
return this._model;
get id(): string {
return this.notebookParams?.notebookUri?.toString();
}
get modelReady(): Promise<INotebookModel> {
return Promise.resolve(this._model);
return Promise.resolve(this.model);
}
// Normally one needs to provide either the editor or the instantiationService as the constructor parameter
constructor({ cellGuid, instantiationService, editor, model }: { cellGuid?: string; instantiationService?: IInstantiationService; editor?: QueryTextEditor; model?: INotebookModel } = {}) {
constructor({ cellGuid, instantiationService, editor, model, notebookParams }: { cellGuid?: string; instantiationService?: IInstantiationService; editor?: QueryTextEditor; model?: INotebookModel, notebookParams?: INotebookParams } = {}) {
super();
this._model = model;
this.model = model;
this.notebookParams = notebookParams;
this.cellEditors = [new CellEditorProviderStub({ cellGuid: cellGuid, instantiationService: instantiationService, editor: editor })];
}
}