mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-25 22:30:29 -04:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -8,7 +8,6 @@ import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TelemetryServiceStub } from 'sqltest/stubs/telemetryServiceStub';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as assert from 'assert';
|
||||
|
||||
suite('SQL Telemetry Utilities tests', () => {
|
||||
@@ -37,7 +36,7 @@ suite('SQL Telemetry Utilities tests', () => {
|
||||
|
||||
setup(() => {
|
||||
telemetryService = TypeMoq.Mock.ofType(TelemetryServiceStub, TypeMoq.MockBehavior.Strict);
|
||||
telemetryService.setup(x => x.publicLog(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(x => TPromise.as(none));
|
||||
telemetryService.setup(x => x.publicLog(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(x => Promise.resolve(none));
|
||||
});
|
||||
|
||||
test('addTelemetry should add provider id using the connection', (done) => {
|
||||
|
||||
@@ -15,7 +15,6 @@ import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfig
|
||||
import { IConfigurationValue, ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as assert from 'assert';
|
||||
import { ProviderFeatures, ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
@@ -27,7 +27,6 @@ import { ResourceProviderStub } from 'sqltest/stubs/resourceProviderServiceStub'
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfigurationTestService';
|
||||
|
||||
import * as assert from 'assert';
|
||||
@@ -95,14 +94,14 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
let root = new ConnectionProfileGroup(ConnectionProfileGroup.RootGroupName, undefined, ConnectionProfileGroup.RootGroupName, undefined, undefined);
|
||||
root.connections = [ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile)];
|
||||
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined)).returns(() => TPromise.as(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined)).returns(() => TPromise.as(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => TPromise.as(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny())).returns(() => TPromise.as(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined)).returns(() => Promise.resolve(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined)).returns(() => Promise.resolve(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(none));
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny())).returns(() => Promise.resolve(none));
|
||||
|
||||
connectionStore.setup(x => x.addActiveConnection(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
connectionStore.setup(x => x.saveProfile(TypeMoq.It.isAny())).returns(() => Promise.resolve(connectionProfile));
|
||||
workbenchEditorService.setup(x => x.openEditor(undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => TPromise.as(undefined));
|
||||
workbenchEditorService.setup(x => x.openEditor(undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is<IConnectionProfile>(
|
||||
c => c.serverName === connectionProfile.serverName))).returns(() => Promise.resolve({ profile: connectionProfile, savedCred: true }));
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is<IConnectionProfile>(
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
@@ -27,7 +26,6 @@ import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { ServerTreeDataSource } from 'sql/parts/objectExplorer/viewlet/serverTreeDataSource';
|
||||
import { Builder, $ } from 'sql/base/browser/builder';
|
||||
import WinJS = require('vs/base/common/winjs.base');
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ObjectExplorerActionsContext, ManageConnectionAction } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
|
||||
@@ -202,7 +200,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve({}));
|
||||
return new Promise((resolve) => resolve({}));
|
||||
});
|
||||
|
||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
@@ -219,7 +217,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve({}));
|
||||
return new Promise((resolve) => resolve({}));
|
||||
});
|
||||
|
||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
@@ -237,7 +235,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve({}));
|
||||
return new Promise((resolve) => resolve({}));
|
||||
});
|
||||
|
||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
@@ -254,7 +252,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve({}));
|
||||
return new Promise((resolve) => resolve({}));
|
||||
});
|
||||
|
||||
let serverTreeView = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Strict, undefined, instantiationService.object, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
@@ -401,15 +399,15 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object);
|
||||
objectExplorerService.callBase = true;
|
||||
objectExplorerService.setup(x => x.getObjectExplorerNode(TypeMoq.It.isAny())).returns(() => tablesNode);
|
||||
objectExplorerService.setup(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => TPromise.as([table1Node, table2Node]));
|
||||
objectExplorerService.setup(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve([table1Node, table2Node]));
|
||||
let builder: Builder = $().div();
|
||||
var dataSource = new ServerTreeDataSource(objectExplorerService.object, connectionManagementService.object, undefined);
|
||||
let tree = TypeMoq.Mock.ofType(Tree, TypeMoq.MockBehavior.Loose, builder.getHTMLElement(), { dataSource });
|
||||
tree.callBase = true;
|
||||
|
||||
tree.setup(x => x.refresh(TypeMoq.It.isAny())).returns(() => WinJS.TPromise.as(null));
|
||||
tree.setup(x => x.expand(TypeMoq.It.isAny())).returns(() => WinJS.TPromise.as(null));
|
||||
tree.setup(x => x.collapse(TypeMoq.It.isAny())).returns(() => WinJS.TPromise.as(null));
|
||||
tree.setup(x => x.refresh(TypeMoq.It.isAny())).returns(() => Promise.resolve(null));
|
||||
tree.setup(x => x.expand(TypeMoq.It.isAny())).returns(() => Promise.resolve(null));
|
||||
tree.setup(x => x.collapse(TypeMoq.It.isAny())).returns(() => Promise.resolve(null));
|
||||
let connectionAction: RefreshAction = new RefreshAction(RefreshAction.ID,
|
||||
RefreshAction.LABEL,
|
||||
tree.object,
|
||||
@@ -424,7 +422,9 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
objectExplorerService.verify(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
tree.verify(x => x.refresh(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
tree.verify(x => x.expand(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
}).then(() => done(), (err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
test('RefreshConnectionAction - refresh should not be called if connection status is not connect', (done) => {
|
||||
@@ -488,14 +488,14 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object);
|
||||
objectExplorerService.callBase = true;
|
||||
objectExplorerService.setup(x => x.getObjectExplorerNode(TypeMoq.It.isAny())).returns(() => tablesNode);
|
||||
objectExplorerService.setup(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => TPromise.as([table1Node, table2Node]));
|
||||
objectExplorerService.setup(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve([table1Node, table2Node]));
|
||||
let builder: Builder = $().div();
|
||||
var dataSource = new ServerTreeDataSource(objectExplorerService.object, connectionManagementService.object, undefined);
|
||||
let tree = TypeMoq.Mock.ofType(Tree, TypeMoq.MockBehavior.Loose, builder.getHTMLElement(), { dataSource });
|
||||
tree.callBase = true;
|
||||
|
||||
tree.setup(x => x.refresh(TypeMoq.It.isAny())).returns(() => WinJS.TPromise.as(null));
|
||||
tree.setup(x => x.expand(TypeMoq.It.isAny())).returns(() => WinJS.TPromise.as(null));
|
||||
tree.setup(x => x.refresh(TypeMoq.It.isAny())).returns(() => Promise.resolve(null));
|
||||
tree.setup(x => x.expand(TypeMoq.It.isAny())).returns(() => Promise.resolve(null));
|
||||
let connectionAction: RefreshAction = new RefreshAction(RefreshAction.ID,
|
||||
RefreshAction.LABEL,
|
||||
tree.object,
|
||||
|
||||
@@ -12,7 +12,6 @@ import { ObjectExplorerService, NodeExpandInfoWithProviderId } from 'sql/workben
|
||||
import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import { TreeNode, TreeItemCollapsibleState } from 'sql/parts/objectExplorer/common/treeNode';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as azdata from 'azdata';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
@@ -281,11 +280,11 @@ suite('SQL Object Explorer Service tests', () => {
|
||||
}));
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.isAny())).callback(() => {
|
||||
objectExplorerService.onNodeExpanded(objectExplorerExpandInfo);
|
||||
}).returns(() => TPromise.as(true));
|
||||
}).returns(() => Promise.resolve(true));
|
||||
sqlOEProvider.setup(x => x.refreshNode(TypeMoq.It.isAny())).callback(() => {
|
||||
objectExplorerService.onNodeExpanded(objectExplorerExpandInfoRefresh);
|
||||
}).returns(() => TPromise.as(true));
|
||||
sqlOEProvider.setup(x => x.closeSession(TypeMoq.It.isAny())).returns(() => TPromise.as(objectExplorerCloseSessionResponse));
|
||||
}).returns(() => Promise.resolve(true));
|
||||
sqlOEProvider.setup(x => x.closeSession(TypeMoq.It.isAny())).returns(() => Promise.resolve(objectExplorerCloseSessionResponse));
|
||||
|
||||
objectExplorerService.onUpdateObjectExplorerNodes(args => {
|
||||
if (args && args.errorMessage !== undefined) {
|
||||
@@ -552,7 +551,7 @@ suite('SQL Object Explorer Service tests', () => {
|
||||
objectExplorerService.resolveTreeNodeChildren(objectExplorerSession, objectExplorerService.getObjectExplorerNode(connection)).then(childNodes => {
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.isAny())).callback(() => {
|
||||
objectExplorerService.onNodeExpanded(tableExpandInfo);
|
||||
}).returns(() => TPromise.as(true));
|
||||
}).returns(() => Promise.resolve(true));
|
||||
let tableNode = childNodes.find(node => node.nodePath === table1NodePath);
|
||||
objectExplorerService.resolveTreeNodeChildren(objectExplorerSession, tableNode).then(() => {
|
||||
// If I check whether the table is expanded, the answer should be yes
|
||||
@@ -610,7 +609,7 @@ suite('SQL Object Explorer Service tests', () => {
|
||||
objectExplorerService.resolveTreeNodeChildren(objectExplorerSession, objectExplorerService.getObjectExplorerNode(connection)).then(childNodes => {
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.isAny())).callback(() => {
|
||||
objectExplorerService.onNodeExpanded(tableExpandInfo);
|
||||
}).returns(() => TPromise.as(true));
|
||||
}).returns(() => Promise.resolve(true));
|
||||
objectExplorerService.resolveTreeNodeChildren(objectExplorerSession, childNodes.find(node => node.nodePath === table1NodePath)).then(() => {
|
||||
// If I check whether the table is expanded, the answer should be yes
|
||||
let tableNode = childNodes.find(node => node.nodePath === table1NodePath);
|
||||
@@ -639,7 +638,7 @@ suite('SQL Object Explorer Service tests', () => {
|
||||
// Set up the OE provider so that the second expand call expands the table
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.is(nodeInfo => nodeInfo.nodePath === table1NodePath))).callback(() => {
|
||||
objectExplorerService.onNodeExpanded(tableExpandInfo);
|
||||
}).returns(() => TPromise.as(true));
|
||||
}).returns(() => Promise.resolve(true));
|
||||
serverTreeView.setup(x => x.setExpandedState(TypeMoq.It.isAny(), TypeMoq.It.is(state => state === TreeItemCollapsibleState.Expanded))).returns(treeNode => {
|
||||
if (treeNode instanceof ConnectionProfile) {
|
||||
treeNode = objectExplorerService.getObjectExplorerNode(treeNode);
|
||||
@@ -768,7 +767,7 @@ suite('SQL Object Explorer Service tests', () => {
|
||||
|
||||
// Set up the provider to not respond to the second expand request, simulating a request that takes a long time to complete
|
||||
const nodePath = objectExplorerSession.rootNode.nodePath;
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.is(x => x.nodePath === nodePath))).callback(() => { }).returns(() => TPromise.as(true));
|
||||
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.is(x => x.nodePath === nodePath))).callback(() => { }).returns(() => Promise.resolve(true));
|
||||
|
||||
// If I queue a second expand request (the first completes normally because of the original mock) and then close the session
|
||||
await objectExplorerService.expandNode(providerId, objectExplorerSession, objectExplorerSession.rootNode.nodePath);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
'use strict';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
import { ISelectionData } from 'azdata';
|
||||
|
||||
@@ -122,7 +121,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
connectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => TPromise.as(none));
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object);
|
||||
@@ -227,7 +226,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
showDialogConnectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => TPromise.as(none));
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "getSelection" in QueryEditor
|
||||
let queryInput = TypeMoq.Mock.ofType(QueryInput, TypeMoq.MockBehavior.Loose);
|
||||
@@ -385,7 +384,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
connectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => TPromise.as(none));
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object);
|
||||
@@ -431,7 +430,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
calledShowDialog++;
|
||||
connectionParams = params;
|
||||
})
|
||||
.returns(() => TPromise.as(none));
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Memento } from 'vs/workbench/common/memento';
|
||||
@@ -86,10 +85,10 @@ suite('SQL QueryEditor Tests', () => {
|
||||
// Mock InstantiationService to give us our mockEditor
|
||||
instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve(mockEditor));
|
||||
return new Promise((resolve) => resolve(mockEditor));
|
||||
});
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve(new RunQueryAction(undefined, undefined, undefined)));
|
||||
return new Promise((resolve) => resolve(new RunQueryAction(undefined, undefined, undefined)));
|
||||
});
|
||||
// Setup hook to capture calls to create the listDatabase action
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
||||
@@ -339,7 +338,7 @@ suite('SQL QueryEditor Tests', () => {
|
||||
queryActionInstantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
|
||||
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new TPromise((resolve) => resolve(mockEditor));
|
||||
return new Promise((resolve) => resolve(mockEditor));
|
||||
});
|
||||
|
||||
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
||||
|
||||
@@ -38,40 +38,41 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||
mockTree = TypeMoq.Mock.ofInstance(tree);
|
||||
(serverTreeView as any)._tree = mockTree.object;
|
||||
mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function);
|
||||
mockRefreshTreeMethod.setup(x => x()).returns(() => Promise.resolve());
|
||||
(serverTreeView as any).refreshTree = mockRefreshTreeMethod.object;
|
||||
mockTree.setup(x => x.clearSelection());
|
||||
mockTree.setup(x => x.select(TypeMoq.It.isAny()));
|
||||
});
|
||||
|
||||
function runAddConnectionProfileHandler(oldSelection, newProfile) {
|
||||
async function runAddConnectionProfileHandler(oldSelection, newProfile): Promise<void> {
|
||||
mockTree.setup(x => x.getSelection()).returns(() => [oldSelection] || []);
|
||||
(serverTreeView as any).handleAddConnectionProfile(newProfile);
|
||||
return (serverTreeView as any).handleAddConnectionProfile(newProfile);
|
||||
}
|
||||
|
||||
test('onAddConnectionProfile handler selects the new profile when no profile is already selected', () => {
|
||||
test('onAddConnectionProfile handler selects the new profile when no profile is already selected', async () => {
|
||||
let newProfile = <IConnectionProfile>{
|
||||
id: 'test_connection'
|
||||
};
|
||||
runAddConnectionProfileHandler(undefined, newProfile);
|
||||
await runAddConnectionProfileHandler(undefined, newProfile);
|
||||
mockRefreshTreeMethod.verify(x => x(), TypeMoq.Times.once());
|
||||
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never());
|
||||
mockTree.verify(x => x.select(TypeMoq.It.is(profile => profile === newProfile)), TypeMoq.Times.once());
|
||||
});
|
||||
|
||||
test('onAddConnectionProfile handler selects the new profile when a different profile is already selected', () => {
|
||||
test('onAddConnectionProfile handler selects the new profile when a different profile is already selected', async () => {
|
||||
let oldProfile = <IConnectionProfile>{
|
||||
id: 'old_connection'
|
||||
};
|
||||
let newProfile = <IConnectionProfile>{
|
||||
id: 'test_connection'
|
||||
};
|
||||
runAddConnectionProfileHandler(oldProfile, newProfile);
|
||||
await runAddConnectionProfileHandler(oldProfile, newProfile);
|
||||
mockRefreshTreeMethod.verify(x => x(), TypeMoq.Times.once());
|
||||
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.once());
|
||||
mockTree.verify(x => x.select(TypeMoq.It.is(profile => profile === newProfile)), TypeMoq.Times.once());
|
||||
});
|
||||
|
||||
test('onAddConnectionProfile handler does not clear the selection when the new profile is already selected', () => {
|
||||
test('onAddConnectionProfile handler does not clear the selection when the new profile is already selected', async () => {
|
||||
let selectionId = 'test_connection';
|
||||
let oldProfile = <IConnectionProfile>{
|
||||
id: selectionId
|
||||
@@ -79,17 +80,17 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||
let newProfile = <IConnectionProfile>{
|
||||
id: selectionId
|
||||
};
|
||||
runAddConnectionProfileHandler(oldProfile, newProfile);
|
||||
await runAddConnectionProfileHandler(oldProfile, newProfile);
|
||||
mockRefreshTreeMethod.verify(x => x(), TypeMoq.Times.once());
|
||||
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never());
|
||||
mockTree.verify(x => x.select(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
});
|
||||
|
||||
test('onAddConnectionProfile handler does not clear the previously selected profile if there is no new one', () => {
|
||||
test('onAddConnectionProfile handler does not clear the previously selected profile if there is no new one', async () => {
|
||||
let oldProfile = <IConnectionProfile>{
|
||||
id: 'test_connection'
|
||||
};
|
||||
runAddConnectionProfileHandler(oldProfile, undefined);
|
||||
await runAddConnectionProfileHandler(oldProfile, undefined);
|
||||
mockRefreshTreeMethod.verify(x => x(), TypeMoq.Times.once());
|
||||
mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never());
|
||||
mockTree.verify(x => x.select(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
|
||||
@@ -9,7 +9,6 @@ import * as azdata from 'azdata';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IAccountManagementService } from 'sql/platform/accountManagement/common/interfaces';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accountManagement/common/eventTypes';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
export class AccountManagementTestService implements IAccountManagementService {
|
||||
_serviceBrand: any;
|
||||
@@ -62,7 +61,7 @@ export class AccountManagementTestService implements IAccountManagementService {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
openAccountListDialog(): TPromise<any> {
|
||||
openAccountListDialog(): Promise<any> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
'use strict';
|
||||
|
||||
import { INewConnectionParams, IConnectionResult, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
|
||||
|
||||
@@ -14,19 +13,19 @@ export class ConnectionDialogTestService implements IConnectionDialogService {
|
||||
|
||||
public showDialog(
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
params: INewConnectionParams, model: IConnectionProfile, connectionResult?: IConnectionResult): TPromise<void> {
|
||||
params: INewConnectionParams, model: IConnectionProfile, connectionResult?: IConnectionResult): Promise<void> {
|
||||
let none: void;
|
||||
return TPromise.as(none);
|
||||
return Promise.resolve(none);
|
||||
}
|
||||
|
||||
public openDialogAndWait(
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): TPromise<IConnectionProfile> {
|
||||
return TPromise.as(undefined);
|
||||
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise<IConnectionProfile> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public openDialogAndWaitButDontConnect(connectionManagementService: IConnectionManagementService,
|
||||
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): TPromise<IConnectionProfile> {
|
||||
return TPromise.as(undefined);
|
||||
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise<IConnectionProfile> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { CredentialManagementEvents, ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
@@ -20,17 +19,17 @@ export class CredentialsTestProvider implements azdata.CredentialProvider {
|
||||
credentialId: credentialId,
|
||||
password: password
|
||||
};
|
||||
return TPromise.as(true);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
readCredential(credentialId: string): Thenable<azdata.Credential> {
|
||||
return TPromise.as(this.storedCredentials[credentialId]);
|
||||
return Promise.resolve(this.storedCredentials[credentialId]);
|
||||
}
|
||||
|
||||
deleteCredential(credentialId: string): Thenable<boolean> {
|
||||
let exists = this.storedCredentials[credentialId] !== undefined;
|
||||
delete this.storedCredentials[credentialId];
|
||||
return TPromise.as(exists);
|
||||
return Promise.resolve(exists);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
/*
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IConfirmation, IMessageService, IMessageWithAction, IConfirmationResult } from 'vs/platform/message/common/message';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
export class MessageServiceStub implements IMessageService {
|
||||
_serviceBrand: any;
|
||||
@@ -35,7 +34,7 @@ export class MessageServiceStub implements IMessageService {
|
||||
}
|
||||
|
||||
|
||||
confirmWithCheckbox(confirmation: IConfirmation): TPromise<IConfirmationResult> {
|
||||
confirmWithCheckbox(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { ITelemetryService, ITelemetryData, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
// Test stubs for commonly used objects
|
||||
|
||||
@@ -15,11 +14,11 @@ export class TelemetryServiceStub implements ITelemetryService {
|
||||
* Sends a telemetry event that has been privacy approved.
|
||||
* Do not call this unless you have been given approval.
|
||||
*/
|
||||
publicLog(eventName: string, data?: ITelemetryData): TPromise<void> {
|
||||
publicLog(eventName: string, data?: ITelemetryData): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import { IEditorService, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, IResourceEditor, IR
|
||||
import { ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IEditorOptions, IResourceInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IEditor, IEditorInput, IResourceDiffInput, IResourceSideBySideInput, GroupIdentifier, ITextEditor, IUntitledResourceInput, ITextDiffEditor, ITextSideBySideEditor, IEditorInputWithOptions } from 'vs/workbench/common/editor';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IEditorGroup, IEditorReplacement } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
@@ -46,30 +45,30 @@ export class WorkbenchEditorTestService implements IEditorService {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<IEditor>;
|
||||
public openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<ITextEditor>;
|
||||
public openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<ITextDiffEditor>;
|
||||
public openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<ITextSideBySideEditor>;
|
||||
public openEditor(input: any, arg2?: any, arg3?: any): TPromise<IEditor> {
|
||||
public openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<IEditor>;
|
||||
public openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextEditor>;
|
||||
public openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextDiffEditor>;
|
||||
public openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextSideBySideEditor>;
|
||||
public openEditor(input: any, arg2?: any, arg3?: any): Promise<IEditor> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<ReadonlyArray<IEditor>>;
|
||||
public openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise<ReadonlyArray<IEditor>>;
|
||||
public openEditors(editors: any[]): TPromise<IEditor[]> {
|
||||
public openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ReadonlyArray<IEditor>>;
|
||||
public openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ReadonlyArray<IEditor>>;
|
||||
public openEditors(editors: any[]): Promise<IEditor[]> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise<void>;
|
||||
public replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise<void>;
|
||||
public replaceEditors(editors: any[], group: any): TPromise<void> {
|
||||
public replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): Promise<void>;
|
||||
public replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): Promise<void>;
|
||||
public replaceEditors(editors: any[], group: any): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the editor at the provided position.
|
||||
*/
|
||||
closeEditor(position: Position, input: IEditorInput): TPromise<void> {
|
||||
closeEditor(position: Position, input: IEditorInput): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -78,14 +77,14 @@ export class WorkbenchEditorTestService implements IEditorService {
|
||||
* will not be closed. The direction can be used in that case to control if all other editors should get closed,
|
||||
* or towards a specific direction.
|
||||
*/
|
||||
closeEditors(p1?: any, p2?: any, p3?: any): TPromise<void> {
|
||||
closeEditors(p1?: any, p2?: any, p3?: any): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes all editors across all groups. The optional position allows to keep one group alive.
|
||||
*/
|
||||
closeAllEditors(except?: Position): TPromise<void> {
|
||||
closeAllEditors(except?: Position): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
export async function assertThrowsAsync(fn, regExp?: any): Promise<void> {
|
||||
let f = () => {
|
||||
// Empty
|
||||
};
|
||||
export async function assertThrowsAsync(fn, expectedMessage?: string): Promise<void> {
|
||||
var threw = false;
|
||||
try {
|
||||
await fn();
|
||||
} catch (e) {
|
||||
f = () => { throw e; };
|
||||
} finally {
|
||||
assert.throws(f, regExp);
|
||||
threw = true;
|
||||
if (expectedMessage) {
|
||||
assert.strictEqual(e.message, expectedMessage);
|
||||
}
|
||||
}
|
||||
assert.equal(threw, true, 'Expected function to throw but it did not');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user