Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)

This commit is contained in:
Cory Rivera
2021-08-25 16:28:29 -07:00
committed by GitHub
parent ab1112bfb3
commit cb7b7da0a4
1752 changed files with 59525 additions and 33878 deletions

View File

@@ -15,7 +15,7 @@ import { DataResourceDataProvider } from '../../browser/outputs/gridOutput.compo
import { IDataResource } from 'sql/workbench/services/notebook/browser/sql/sqlSessionManager';
import { ResultSetSummary } from 'sql/workbench/services/query/common/query';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { TestFileDialogService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestFileDialogService, TestEditorService, TestPathService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { SerializationService } from 'sql/platform/serialization/common/serializationService';
import { SaveFormat, ResultSerializer } from 'sql/workbench/services/query/common/resultSerializer';
@@ -47,7 +47,7 @@ export class TestSerializationProvider implements azdata.SerializationProvider {
}
suite('Data Resource Data Provider', function () {
let fileDialogService: TypeMoq.Mock<TestFileDialogService>;
let fileDialogService: TestFileDialogService;
let serializer: ResultSerializer;
let notificationService: TestNotificationService;
let serializationService: SerializationService;
@@ -75,7 +75,8 @@ suite('Data Resource Data Provider', function () {
let editorService = TypeMoq.Mock.ofType(TestEditorService, TypeMoq.MockBehavior.Strict);
editorService.setup(x => x.openEditor(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let contextService = new TestContextService();
fileDialogService = TypeMoq.Mock.ofType(TestFileDialogService, TypeMoq.MockBehavior.Strict);
let pathService = new TestPathService();
fileDialogService = new TestFileDialogService(pathService);
notificationService = new TestNotificationService();
serializationService = new SerializationService(undefined, undefined); //_connectionService _capabilitiesService
serializationService.registerProvider('testProviderId', new TestSerializationProvider());
@@ -84,7 +85,7 @@ suite('Data Resource Data Provider', function () {
undefined, // IConfigurationService
editorService.object,
contextService,
fileDialogService.object,
fileDialogService,
notificationService,
undefined // IOpenerService
);
@@ -108,15 +109,15 @@ suite('Data Resource Data Provider', function () {
instantiationService.object
);
let noHeadersFile = URI.file(path.join(tempFolderPath, 'result_noHeaders.csv'));
let fileDialogServiceStub = sinon.stub(fileDialogService.object, 'showSaveDialog').returns(Promise.resolve(noHeadersFile));
let serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns({ resultFormat: SaveFormat.CSV as string, includeHeaders: false });
let fileDialogServiceStub = sinon.stub(fileDialogService, 'showSaveDialog').returns(Promise.resolve(noHeadersFile));
let serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns(<azdata.SaveResultsRequestParams>{ resultFormat: SaveFormat.CSV as string, includeHeaders: false });
await dataResourceDataProvider.serializeResults(SaveFormat.CSV, undefined);
fileDialogServiceStub.restore();
serializerStub.restore();
let withHeadersFile = URI.file(path.join(tempFolderPath, 'result_withHeaders.csv'));
fileDialogServiceStub = sinon.stub(fileDialogService.object, 'showSaveDialog').returns(Promise.resolve(withHeadersFile));
serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns({ resultFormat: SaveFormat.CSV as string, includeHeaders: true });
fileDialogServiceStub = sinon.stub(fileDialogService, 'showSaveDialog').returns(Promise.resolve(withHeadersFile));
serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns(<azdata.SaveResultsRequestParams>{ resultFormat: SaveFormat.CSV as string, includeHeaders: true });
await dataResourceDataProvider.serializeResults(SaveFormat.CSV, undefined);
fileDialogServiceStub.restore();
serializerStub.restore();

View File

@@ -73,7 +73,7 @@ suite('MarkdownTextTransformer', () => {
undefined,
undefined,
);
mockNotebookService = TypeMoq.Mock.ofInstance(notebookService);
mockNotebookService = TypeMoq.Mock.ofInstance<INotebookService>(notebookService);
cellModel = new CellModel(undefined, undefined, mockNotebookService.object);
notebookEditor = new NotebookEditorStub({ cellGuid: cellModel.cellGuid, instantiationService: instantiationService });

View File

@@ -577,7 +577,7 @@ suite('Notebook Actions', function (): void {
let setOptionsSpy: sinon.SinonSpy;
setup(async () => {
sandbox = sinon.sandbox.create();
sandbox = sinon.createSandbox();
container = document.createElement('div');
contextViewProvider = new ContextViewProviderStub();
const instantiationService = <TestInstantiationService>workbenchInstantiationService();

View File

@@ -44,7 +44,6 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { EditorOptions } from 'vs/workbench/common/editor';
import { ICell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -58,6 +57,7 @@ import { workbenchInstantiationService } from 'vs/workbench/test/browser/workben
import { IProductService } from 'vs/platform/product/common/productService';
import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService';
import { CellModel } from 'sql/workbench/services/notebook/browser/models/cell';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
class NotebookModelStub extends stubs.NotebookModelStub {
public contentChangedEmitter = new Emitter<NotebookContentChange>();
@@ -132,7 +132,7 @@ suite('Test class NotebookEditor:', () => {
const testNotebookEditor = new NotebookEditorStub({ cellGuid: cellTextEditorGuid, editor: queryTextEditor, model: notebookModel, notebookParams: <INotebookParams>{ notebookUri: untitledNotebookInput.notebookUri } });
notebookService.addNotebookEditor(testNotebookEditor);
notebookEditor.clearInput();
await notebookEditor.setInput(untitledNotebookInput, EditorOptions.create({ pinned: true }), undefined);
await notebookEditor.setInput(untitledNotebookInput, { pinned: true }, undefined);
untitledNotebookInput.notebookFindModel.notebookModel = undefined; // clear preexisting notebookModel
const result = await notebookEditor.getNotebookModel();
assert.strictEqual(result, notebookModel, `getNotebookModel() should return the model set in the INotebookEditor object`);
@@ -215,7 +215,7 @@ suite('Test class NotebookEditor:', () => {
test('Tests setInput call with various states of input on a notebookEditor object', async () => {
createEditor(notebookEditor);
const editorOptions = EditorOptions.create({ pinned: true });
const editorOptions: IEditorOptions = { pinned: true };
for (const input of [
untitledNotebookInput /* set to a known input */,
untitledNotebookInput /* tries to set the same input that was previously set */
@@ -227,7 +227,7 @@ suite('Test class NotebookEditor:', () => {
test('Tests setInput call with various states of findState.isRevealed on a notebookEditor object', async () => {
createEditor(notebookEditor);
const editorOptions = EditorOptions.create({ pinned: true });
const editorOptions: IEditorOptions = { pinned: true };
for (const isRevealed of [true, false]) {
notebookEditor['_findState']['_isRevealed'] = isRevealed;
notebookEditor.clearInput();
@@ -754,7 +754,7 @@ async function setupNotebookEditor(notebookEditor: NotebookEditor, untitledNoteb
}
async function setInputDocument(notebookEditor: NotebookEditor, untitledNotebookInput: UntitledNotebookInput): Promise<void> {
const editorOptions = EditorOptions.create({ pinned: true });
const editorOptions: IEditorOptions = { pinned: true };
await notebookEditor.setInput(untitledNotebookInput, editorOptions, undefined);
assert.strictEqual(notebookEditor.options, editorOptions, 'NotebookEditor options must be the ones that we set');
}

View File

@@ -20,6 +20,7 @@ import { IExtensionService, NullExtensionService } from 'vs/workbench/services/e
import { INotebookService, IProviderInfo } from 'sql/workbench/services/notebook/browser/notebookService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { EditorInputCapabilities } from 'vs/workbench/common/editor';
suite('Notebook Input', function (): void {
const instantiationService = workbenchInstantiationService();
@@ -64,13 +65,13 @@ suite('Notebook Input', function (): void {
let inputId = fileNotebookInput.typeId;
assert.strictEqual(inputId, FileNotebookInput.ID);
assert.strictEqual(fileNotebookInput.isUntitled(), false, 'File Input should not be untitled');
assert.strictEqual(fileNotebookInput.hasCapability(EditorInputCapabilities.Untitled), false, 'File Input should not be untitled');
});
test('Untitled Notebook Input', async function (): Promise<void> {
let inputId = untitledNotebookInput.typeId;
assert.strictEqual(inputId, UntitledNotebookInput.ID);
assert.ok(untitledNotebookInput.isUntitled(), 'Untitled Input should be untitled');
assert.ok(untitledNotebookInput.hasCapability(EditorInputCapabilities.Untitled), 'Untitled Input should be untitled');
});
test('Getters and Setters', async function (): Promise<void> {

View File

@@ -164,7 +164,7 @@ suite.skip('NotebookService:', function (): void {
notebookService = new NotebookService(lifecycleService, storageService, extensionServiceMock.object, extensionManagementService,
instantiationService, fileService, logServiceMock.object, queryManagementService, contextService, productService,
editorService, untitledTextEditorService, editorGroupsService, configurationService);
sandbox = sinon.sandbox.create();
sandbox = sinon.createSandbox();
});
teardown(() => {
@@ -412,7 +412,7 @@ suite.skip('NotebookService:', function (): void {
id: 'id1'
}
});
const targetMethodSpy = sandbox.spy(notebookService, methodName);
const targetMethodSpy = sandbox.spy(notebookService, methodName as keyof NotebookService);
didUninstallExtensionEmitter.fire(extensionIdentifier);
assert.ok(targetMethodSpy.calledWithExactly(extensionIdentifier.identifier, extensionServiceMock.object), `call arguments to ${methodName} should be ${extensionIdentifier.identifier} & ${extensionServiceMock.object}`);
assert.ok(targetMethodSpy.calledOnce, `${methodName} should be called exactly once`);
@@ -432,7 +432,7 @@ suite.skip('NotebookService:', function (): void {
id: 'id1'
}
});
const targetMethodSpy = sandbox.spy(notebookService, methodName);
const targetMethodSpy = sandbox.spy(notebookService, methodName as keyof NotebookService);
// the following call will encounter an exception internally with extensionService.getExtensions() returning undefined.
didUninstallExtensionEmitter.fire(extensionIdentifier);
assert.ok(targetMethodSpy.calledWithExactly(extensionIdentifier.identifier, extensionServiceMock.object), `call arguments to ${methodName} should be ${extensionIdentifier.identifier} & ${extensionServiceMock.object}`);

View File

@@ -240,8 +240,8 @@ suite('NotebookViewModel', function (): void {
function setupServices() {
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
notebookManagers[0].sessionManager = mockSessionManager.object;
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());

View File

@@ -73,7 +73,7 @@ suite('Notebook Views Actions', function (): void {
let sandbox: sinon.SinonSandbox;
setup(() => {
sandbox = sinon.sandbox.create();
sandbox = sinon.createSandbox();
setupServices();
});
@@ -95,7 +95,7 @@ suite('Notebook Views Actions', function (): void {
assert.deepStrictEqual(notebookViews.getActiveView(), newView, 'Active view not set properly');
const deleteAction = new DeleteViewAction(notebookViews, dialogService, notificationService);
sandbox.stub(deleteAction, 'confirmDelete').withArgs(newView).returns(Promise.resolve(true));
sandbox.stub(deleteAction, 'confirmDelete' as keyof DeleteViewAction).withArgs(newView).returns(Promise.resolve(true));
await deleteAction.run();
assert.strictEqual(notebookViews.getViews().length, 0, 'View not deleted');
@@ -116,7 +116,7 @@ suite('Notebook Views Actions', function (): void {
assert.strictEqual(notebookViews.getActiveView(), newView, 'Active view not set properly');
const deleteAction = new DeleteViewAction(notebookViews, dialogService, notificationService);
sandbox.stub(deleteAction, 'confirmDelete').withArgs(newView).returns(Promise.resolve(false));
sandbox.stub(deleteAction, 'confirmDelete' as keyof DeleteViewAction).withArgs(newView).returns(Promise.resolve(false));
await deleteAction.run();
assert.strictEqual(notebookViews.getViews().length, 1, 'View should not have deleted');
@@ -165,8 +165,8 @@ suite('Notebook Views Actions', function (): void {
function setupServices() {
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
notebookManagers[0].sessionManager = mockSessionManager.object;
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());

View File

@@ -132,8 +132,8 @@ suite('NotebookViews', function (): void {
function setupServices() {
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
notebookManagers[0].sessionManager = mockSessionManager.object;
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());

View File

@@ -19,7 +19,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { startsWith } from 'vs/base/common/strings';
import { Schemas } from 'vs/base/common/network';
import { URI } from 'vs/base/common/uri';
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
@@ -741,15 +740,15 @@ suite('Cell Model', function (): void {
let content = JSON.stringify(cell.toJSON(), undefined, ' ');
let contentSplit = content.split('\n');
assert.equal(contentSplit.length, 9);
assert(startsWith(contentSplit[0].trim(), '{'));
assert(startsWith(contentSplit[1].trim(), '"cell_type": "code",'));
assert(startsWith(contentSplit[2].trim(), '"source": ""'));
assert(startsWith(contentSplit[3].trim(), '"metadata": {'));
assert(startsWith(contentSplit[4].trim(), '"azdata_cell_guid": "'));
assert(startsWith(contentSplit[5].trim(), '}'));
assert(startsWith(contentSplit[6].trim(), '"outputs": []'));
assert(startsWith(contentSplit[7].trim(), '"execution_count": null'));
assert(startsWith(contentSplit[8].trim(), '}'));
assert(contentSplit[0].trim().startsWith('{'));
assert(contentSplit[1].trim().startsWith('"cell_type": "code",'));
assert(contentSplit[2].trim().startsWith('"source": ""'));
assert(contentSplit[3].trim().startsWith('"metadata": {'));
assert(contentSplit[4].trim().startsWith('"azdata_cell_guid": "'));
assert(contentSplit[5].trim().startsWith('}'));
assert(contentSplit[6].trim().startsWith('"outputs": []'));
assert(contentSplit[7].trim().startsWith('"execution_count": null'));
assert(contentSplit[8].trim().startsWith('}'));
});
});

View File

@@ -30,7 +30,7 @@ suite('Client Session', function (): void {
notebookManager = new NotebookManagerStub();
notebookManager.serverManager = serverManager;
notebookManager.sessionManager = mockSessionManager.object;
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
session = new ClientSession({
notebookManager: notebookManager,

View File

@@ -58,11 +58,11 @@ suite('Local Content Manager', function (): void {
override async readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
const content = await promisify(fs.readFile)(resource.fsPath);
return { name: ',', size: 0, etag: '', mtime: 0, value: VSBuffer.fromString(content.toString()), resource, ctime: 0 };
return { name: ',', size: 0, etag: '', mtime: 0, value: VSBuffer.fromString(content.toString()), resource, ctime: 0, readonly: false };
}
override async writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {
await pfs.writeFile(resource.fsPath, bufferOrReadable.toString());
return { resource: resource, mtime: 0, etag: '', size: 0, name: '', isDirectory: false, ctime: 0, isFile: true, isSymbolicLink: false };
await pfs.Promises.writeFile(resource.fsPath, bufferOrReadable.toString());
return { resource: resource, mtime: 0, etag: '', size: 0, name: '', isDirectory: false, ctime: 0, isFile: true, isSymbolicLink: false, readonly: false };
}
};
instantiationService.set(IFileService, fileService);

View File

@@ -34,8 +34,6 @@ import { nb } from 'azdata';
import { Emitter } from 'vs/base/common/event';
import { INotebookEditor, INotebookManager } from 'sql/workbench/services/notebook/browser/notebookService';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { startsWith } from 'vs/base/common/strings';
import { assign } from 'vs/base/common/objects';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { TestStorageService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
@@ -172,7 +170,7 @@ suite('Notebook Editor Model', function (): void {
teardown(() => {
if (accessor && accessor.textFileService && accessor.textFileService.files) {
(<TextFileEditorModelManager>accessor.textFileService.files).clear();
(<TextFileEditorModelManager>accessor.textFileService.files).dispose();
}
});
@@ -663,7 +661,7 @@ suite('Notebook Editor Model', function (): void {
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10 + i * 21), ' ],');
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14 + i * 21), ' "outputs": [');
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25 + i * 21), ' "execution_count": null');
assert(startsWith(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21), ' }'));
assert(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21).startsWith(' }'));
}
});
@@ -971,7 +969,7 @@ suite('Notebook Editor Model', function (): void {
});
async function createNewNotebookModel() {
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
factory: mockModelFactory.object
});
notebookModel = new NotebookModel(options, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);

View File

@@ -79,8 +79,8 @@ suite('Notebook Find Model', function (): void {
setup(async () => {
sessionReady = new Deferred<void>();
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny()
)).returns(() => void 0);
@@ -102,7 +102,7 @@ suite('Notebook Find Model', function (): void {
layoutChanged: undefined,
capabilitiesService: capabilitiesService.object
};
mockClientSession = TypeMoq.Mock.ofType(ClientSession, undefined, defaultModelOptions);
mockClientSession = TypeMoq.Mock.ofType<IClientSession>(ClientSession, undefined, defaultModelOptions);
mockClientSession.setup(c => c.initialize()).returns(() => {
return Promise.resolve();
});

View File

@@ -29,7 +29,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
import { NullLogService } from 'vs/platform/log/common/log';
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { assign } from 'vs/base/common/objects';
import { NotebookEditorContentManager } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
import { SessionManager } from 'sql/workbench/contrib/notebook/test/emptySessionClasses';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
@@ -38,7 +37,6 @@ import { uriPrefixes } from 'sql/platform/connection/common/utils';
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
let expectedNotebookContent: nb.INotebookContents = {
cells: [{
@@ -150,7 +148,7 @@ suite('notebook model', function (): void {
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
notebookManagers[0].sessionManager = mockSessionManager.object;
sessionReady = new Deferred<void>();
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = new TestCapabilitiesService();
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
@@ -747,13 +745,13 @@ suite('notebook model', function (): void {
assert(!isUndefinedOrNull(model.context), 'context should exist after call to change context');
let notebookKernelAlias = model.context.serverCapabilities.notebookKernelAlias;
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel').withArgs(model.kernelAliases[0]);
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel' as keyof NotebookModel);
model.changeKernel(notebookKernelAlias);
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
assert.equal(model.currentKernelAlias, notebookKernelAlias);
sinon.assert.called(doChangeKernelStub);
sinon.restore(doChangeKernelStub);
sinon.assert.calledWith(doChangeKernelStub, model.kernelAliases[0]);
doChangeKernelStub.restore();
// After closing the notebook
await model.handleClosed();
@@ -774,14 +772,14 @@ suite('notebook model', function (): void {
assert(!isUndefinedOrNull(model.context), 'context should exist after call to change context');
let notebookKernelAlias = model.context.serverCapabilities.notebookKernelAlias;
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel');
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel' as keyof NotebookModel);
// Change kernel first to alias kernel and then connect to SQL connection
model.changeKernel(notebookKernelAlias);
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
assert.equal(model.currentKernelAlias, notebookKernelAlias);
sinon.assert.called(doChangeKernelStub);
sinon.restore(doChangeKernelStub);
doChangeKernelStub.restore();
// Change to SQL connection from Fake connection
await changeContextWithConnectionProfile(model);
@@ -790,7 +788,7 @@ suite('notebook model', function (): void {
assert.equal(model.selectedKernelDisplayName, expectedKernel);
assert.equal(model.currentKernelAlias, undefined);
sinon.assert.called(doChangeKernelStub);
sinon.restore(doChangeKernelStub);
doChangeKernelStub.restore();
// After closing the notebook
await model.handleClosed();
@@ -815,7 +813,7 @@ suite('notebook model', function (): void {
defaultModelOptions.contentManager = mockContentManager.object;
// And a matching connection profile
let expectedConnectionProfile: IConnectionProfile = {
let expectedConnectionProfile = <ConnectionProfile>{
connectionName: connectionName,
serverName: '',
databaseName: '',
@@ -915,7 +913,7 @@ suite('notebook model', function (): void {
sessionReady.resolve();
let actualSession: IClientSession = undefined;
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
factory: mockModelFactory.object
});
let model = new NotebookModel(options, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService, capabilitiesService);