mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 01:25:39 -05:00
Properly expose errors in ads and tests (#8692)
* add code to expose errors outside zone * remove unexpect error hiding * remove uncessary code * fix tests * trying to catch more errros * revert for testing * wip * wip * figured out what was going on * wip * fix tests * fix tests
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
||||
@@ -70,7 +71,7 @@ suite('auto OAuth dialog controller tests', () => {
|
||||
|
||||
});
|
||||
|
||||
test('Open auto OAuth when the flyout is already open, return an error', (done) => {
|
||||
test('Open auto OAuth when the flyout is already open, return an error', async () => {
|
||||
|
||||
// If: Open auto OAuth dialog first time
|
||||
autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);
|
||||
@@ -80,8 +81,8 @@ suite('auto OAuth dialog controller tests', () => {
|
||||
mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
|
||||
// If: a oauth flyout is already open
|
||||
autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri)
|
||||
.then(success => done('Failure: Expected error on 2nd dialog open'), error => done());
|
||||
await autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri)
|
||||
.then(success => assert.fail('Failure: Expected error on 2nd dialog open'), error => Promise.resolve());
|
||||
|
||||
// Then: An error dialog should have been opened
|
||||
mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
|
||||
@@ -19,7 +19,6 @@ import { TestConnectionManagementService } from 'sql/platform/connection/test/co
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { TestCommandService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { assertThrowsAsync } from 'sql/base/test/common/async';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
@@ -139,7 +138,7 @@ suite('commandLineService tests', () => {
|
||||
return configurationService;
|
||||
}
|
||||
|
||||
test('processCommandLine shows connection dialog by default', done => {
|
||||
test('processCommandLine shows connection dialog by default', () => {
|
||||
const connectionManagementService: TypeMoq.Mock<IConnectionManagementService>
|
||||
= TypeMoq.Mock.ofType<IConnectionManagementService>(TestConnectionManagementService, TypeMoq.MockBehavior.Strict);
|
||||
|
||||
@@ -152,10 +151,9 @@ suite('commandLineService tests', () => {
|
||||
.verifiable(TypeMoq.Times.never());
|
||||
const configurationService = getConfigurationServiceMock(true);
|
||||
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object);
|
||||
contribution.processCommandLine(new TestParsedArgs()).then(() => {
|
||||
return contribution.processCommandLine(new TestParsedArgs()).then(() => {
|
||||
connectionManagementService.verifyAll();
|
||||
done();
|
||||
}, error => { assert.fail(error, null, 'processCommandLine rejected ' + error); done(); });
|
||||
}, error => { assert.fail(error, null, 'processCommandLine rejected ' + error); });
|
||||
});
|
||||
|
||||
test('processCommandLine does nothing if no server name and command name is provided and the configuration \'workbench.showConnectDialogOnStartup\' is set to false, even if registered servers exist', async () => {
|
||||
@@ -295,7 +293,10 @@ suite('commandLineService tests', () => {
|
||||
.verifiable(TypeMoq.Times.once());
|
||||
const configurationService = getConfigurationServiceMock(true);
|
||||
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
||||
assertThrowsAsync(async () => await contribution.processCommandLine(args));
|
||||
try {
|
||||
await contribution.processCommandLine(args);
|
||||
assert.fail('expected to throw');
|
||||
} catch (e) { }
|
||||
});
|
||||
|
||||
test('processCommandLine uses Integrated auth if no user name or auth type is passed', async () => {
|
||||
|
||||
@@ -37,9 +37,7 @@ class TestChangeDetectorRef extends ChangeDetectorRef {
|
||||
}
|
||||
|
||||
suite('Dashboard Properties Widget Tests', () => {
|
||||
test('Parses good config', function (done) {
|
||||
// for some reason mocha thinks this test takes 26 seconds even though it doesn't, so it says this failed because it took longer than 2 seconds
|
||||
this.timeout(30000);
|
||||
test('Parses good config', () => {
|
||||
let propertiesConfig = {
|
||||
properties: [
|
||||
{
|
||||
@@ -106,13 +104,15 @@ suite('Dashboard Properties Widget Tests', () => {
|
||||
|
||||
let testComponent = new PropertiesWidgetComponent(dashboardService.object, new TestChangeDetectorRef(), undefined, widgetConfig, testLogService);
|
||||
|
||||
// because config parsing is done async we need to put our asserts on the thread stack
|
||||
setTimeout(() => {
|
||||
// because properties is private we need to do some work arounds to access it.
|
||||
assert.equal((<any>testComponent).properties.length, 1);
|
||||
assert.equal((<any>testComponent).properties[0].displayName, 'Test');
|
||||
assert.equal((<any>testComponent).properties[0].value, 'Test Property');
|
||||
done();
|
||||
return new Promise(resolve => {
|
||||
// because config parsing is done async we need to put our asserts on the thread stack
|
||||
setImmediate(() => {
|
||||
// because properties is private we need to do some work arounds to access it.
|
||||
assert.equal((<any>testComponent).properties.length, 1);
|
||||
assert.equal((<any>testComponent).properties[0].displayName, 'Test');
|
||||
assert.equal((<any>testComponent).properties[0].value, 'Test Property');
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledText
|
||||
import { SimpleUriLabelService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { INotebookService, IProviderInfo } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
|
||||
suite('Notebook Input', function (): void {
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
@@ -41,6 +42,8 @@ suite('Notebook Input', function (): void {
|
||||
}];
|
||||
});
|
||||
|
||||
(instantiationService as TestInstantiationService).stub(INotebookService, mockNotebookService.object);
|
||||
|
||||
let untitledTextInput: UntitledTextEditorInput;
|
||||
let untitledNotebookInput: UntitledNotebookInput;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as tempWrite from 'temp-write';
|
||||
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
|
||||
import * as testUtils from '../../../../../base/test/common/async';
|
||||
import { CellTypes } from 'sql/workbench/contrib/notebook/common/models/contracts';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { TestFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
@@ -73,7 +72,10 @@ suite('Local Content Manager', function (): void {
|
||||
});
|
||||
|
||||
test('Should throw if file does not exist', async function (): Promise<void> {
|
||||
await testUtils.assertThrowsAsync(async () => await contentManager.getNotebookContents(URI.file('/path/doesnot/exist.ipynb')), undefined);
|
||||
try {
|
||||
await contentManager.getNotebookContents(URI.file('/path/doesnot/exist.ipynb'));
|
||||
assert.fail('expected to throw');
|
||||
} catch (e) { }
|
||||
});
|
||||
test('Should return notebook contents parsed as INotebook when valid notebook file parsed', async function (): Promise<void> {
|
||||
// Given a file containing a valid notebook
|
||||
|
||||
@@ -83,7 +83,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
return objectExplorerService;
|
||||
}
|
||||
|
||||
test('ManageConnectionAction - test if connect is called for manage action if not already connected', (done) => {
|
||||
test('ManageConnectionAction - test if connect is called for manage action if not already connected', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
let connection: ConnectionProfile = new ConnectionProfile(capabilitiesService, {
|
||||
connectionName: 'Test',
|
||||
@@ -127,12 +127,12 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
let actionContext = new ObjectExplorerActionsContext();
|
||||
actionContext.connectionProfile = connection.toIConnectionProfile();
|
||||
actionContext.isConnectionNode = true;
|
||||
manageConnectionAction.run(actionContext).then((value) => {
|
||||
return manageConnectionAction.run(actionContext).then(() => {
|
||||
connectionManagementService.verify(x => x.connect(TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny(), undefined), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('ManageConnectionAction - test if connect is called for manage action on database node if not already connected', (done) => {
|
||||
test('ManageConnectionAction - test if connect is called for manage action on database node if not already connected', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
let connection: ConnectionProfile = new ConnectionProfile(capabilitiesService, {
|
||||
connectionName: 'Test',
|
||||
@@ -165,13 +165,13 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
let actionContext = new ObjectExplorerActionsContext();
|
||||
actionContext.connectionProfile = connection.toIConnectionProfile();
|
||||
actionContext.nodeInfo = treeNode.toNodeInfo();
|
||||
manageConnectionAction.run(actionContext).then((value) => {
|
||||
return manageConnectionAction.run(actionContext).then((value) => {
|
||||
connectionManagementService.verify(x => x.showDashboard(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('DisconnectConnectionAction - test if disconnect is called when profile is connected', (done) => {
|
||||
test('DisconnectConnectionAction - test if disconnect is called when profile is connected', () => {
|
||||
let isConnectedReturnValue: boolean = true;
|
||||
let connection: ConnectionProfile = new ConnectionProfile(capabilitiesService, {
|
||||
connectionName: 'Test',
|
||||
@@ -194,23 +194,23 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
|
||||
let actionContext = new ObjectExplorerActionsContext();
|
||||
actionContext.connectionProfile = connection.toIConnectionProfile();
|
||||
changeConnectionAction.run(actionContext).then((value) => {
|
||||
return changeConnectionAction.run(actionContext).then((value) => {
|
||||
connectionManagementService.verify(x => x.isProfileConnected(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
connectionManagementService.verify(x => x.disconnect(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('AddServerAction - test if show connection dialog is called', (done) => {
|
||||
test('AddServerAction - test if show connection dialog is called', () => {
|
||||
let connectionManagementService = createConnectionManagementService(true, undefined);
|
||||
|
||||
let connectionTreeAction: AddServerAction = new AddServerAction(AddServerAction.ID, AddServerAction.LABEL, connectionManagementService.object);
|
||||
let conProfGroup = new ConnectionProfileGroup('testGroup', undefined, 'testGroup', undefined, undefined);
|
||||
connectionTreeAction.run(conProfGroup).then((value) => {
|
||||
return connectionTreeAction.run(conProfGroup).then((value) => {
|
||||
connectionManagementService.verify(x => x.showConnectionDialog(undefined, undefined, TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('ActiveConnectionsFilterAction - test if view is called to display filtered results', (done) => {
|
||||
test('ActiveConnectionsFilterAction - test if view is called to display filtered results', () => {
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
@@ -220,12 +220,12 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||
serverTreeView.setup(x => x.refreshTree());
|
||||
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object);
|
||||
connectionTreeAction.run().then((value) => {
|
||||
return connectionTreeAction.run().then((value) => {
|
||||
serverTreeView.verify(x => x.showFilteredTree('active'), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('ActiveConnectionsFilterAction - test if view is called refresh results if action is toggled', (done) => {
|
||||
test('ActiveConnectionsFilterAction - test if view is called refresh results if action is toggled', () => {
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
@@ -236,12 +236,12 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
serverTreeView.setup(x => x.refreshTree());
|
||||
let connectionTreeAction: ActiveConnectionsFilterAction = new ActiveConnectionsFilterAction(ActiveConnectionsFilterAction.ID, ActiveConnectionsFilterAction.LABEL, serverTreeView.object);
|
||||
connectionTreeAction.isSet = true;
|
||||
connectionTreeAction.run().then((value) => {
|
||||
return connectionTreeAction.run().then((value) => {
|
||||
serverTreeView.verify(x => x.refreshTree(), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('RecentConnectionsFilterAction - test if view is called to display filtered results', (done) => {
|
||||
test('RecentConnectionsFilterAction - test if view is called to display filtered results', () => {
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
@@ -251,12 +251,12 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
serverTreeView.setup(x => x.showFilteredTree(TypeMoq.It.isAnyString()));
|
||||
serverTreeView.setup(x => x.refreshTree());
|
||||
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object);
|
||||
connectionTreeAction.run().then((value) => {
|
||||
return connectionTreeAction.run().then((value) => {
|
||||
serverTreeView.verify(x => x.showFilteredTree('recent'), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('RecentConnectionsFilterAction - test if view is called refresh results if action is toggled', (done) => {
|
||||
test('RecentConnectionsFilterAction - test if view is called refresh results if action is toggled', () => {
|
||||
let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
|
||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
@@ -267,12 +267,12 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
serverTreeView.setup(x => x.refreshTree());
|
||||
let connectionTreeAction: RecentConnectionsFilterAction = new RecentConnectionsFilterAction(RecentConnectionsFilterAction.ID, RecentConnectionsFilterAction.LABEL, serverTreeView.object);
|
||||
connectionTreeAction.isSet = true;
|
||||
connectionTreeAction.run().then((value) => {
|
||||
return connectionTreeAction.run().then((value) => {
|
||||
serverTreeView.verify(x => x.refreshTree(), TypeMoq.Times.once());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
test('DeleteConnectionAction - test delete connection', (done) => {
|
||||
test('DeleteConnectionAction - test delete connection', () => {
|
||||
let connectionManagementService = createConnectionManagementService(true, undefined);
|
||||
|
||||
let connection: ConnectionProfile = new ConnectionProfile(capabilitiesService, {
|
||||
@@ -295,13 +295,13 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
connection,
|
||||
connectionManagementService.object);
|
||||
|
||||
connectionAction.run().then((value) => {
|
||||
return connectionAction.run().then((value) => {
|
||||
connectionManagementService.verify(x => x.deleteConnection(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('DeleteConnectionAction - test delete connection group', (done) => {
|
||||
test('DeleteConnectionAction - test delete connection group', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
let connectionManagementService = createConnectionManagementService(isConnectedReturnValue, undefined);
|
||||
let conProfGroup = new ConnectionProfileGroup('testGroup', undefined, 'testGroup', undefined, undefined);
|
||||
@@ -310,13 +310,13 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
conProfGroup,
|
||||
connectionManagementService.object);
|
||||
|
||||
connectionAction.run().then((value) => {
|
||||
return connectionAction.run().then((value) => {
|
||||
connectionManagementService.verify(x => x.deleteConnectionGroup(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('DeleteConnectionAction - delete should not be called if connect is an unsaved connection', (done) => {
|
||||
test('DeleteConnectionAction - delete should not be called if connect is an unsaved connection', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
let connectionManagementService = createConnectionManagementService(isConnectedReturnValue, undefined);
|
||||
|
||||
@@ -342,10 +342,9 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
connectionManagementService.object);
|
||||
|
||||
assert.equal(connectionAction.enabled, false, 'delete action should be disabled.');
|
||||
done();
|
||||
});
|
||||
|
||||
test('RefreshConnectionAction - refresh should be called if connection status is connect', (done) => {
|
||||
test('RefreshConnectionAction - refresh should be called if connection status is connect', () => {
|
||||
let isConnectedReturnValue: boolean = true;
|
||||
let sqlProvider = {
|
||||
providerId: mssqlProviderName,
|
||||
@@ -423,17 +422,15 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
undefined,
|
||||
logService);
|
||||
|
||||
connectionAction.run().then((value) => {
|
||||
return connectionAction.run().then((value) => {
|
||||
connectionManagementService.verify(x => x.isConnected(undefined, TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
objectExplorerService.verify(x => x.getObjectExplorerNode(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
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());
|
||||
}).then(() => done(), (err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
test('RefreshConnectionAction - refresh should not be called if connection status is not connect', (done) => {
|
||||
test('RefreshConnectionAction - refresh should not be called if connection status is not connect', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
let sqlProvider = {
|
||||
providerId: mssqlProviderName,
|
||||
@@ -510,13 +507,13 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
undefined,
|
||||
logService);
|
||||
|
||||
connectionAction.run().then((value) => {
|
||||
return connectionAction.run().then((value) => {
|
||||
connectionManagementService.verify(x => x.isConnected(undefined, TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
objectExplorerService.verify(x => x.getObjectExplorerNode(TypeMoq.It.isAny()), TypeMoq.Times.exactly(0));
|
||||
objectExplorerService.verify(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.exactly(0));
|
||||
tree.verify(x => x.refresh(TypeMoq.It.isAny()), TypeMoq.Times.exactly(0));
|
||||
tree.verify(x => x.expand(TypeMoq.It.isAny()), TypeMoq.Times.exactly(0));
|
||||
}).then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -77,17 +77,16 @@ suite('SQL QueryAction Tests', () => {
|
||||
testQueryInput.setup(x => x.runQuery(undefined)).callback(() => { calledRunQueryOnInput = true; });
|
||||
});
|
||||
|
||||
test('setClass sets child CSS class correctly', (done) => {
|
||||
test('setClass sets child CSS class correctly', () => {
|
||||
// If I create a RunQueryAction
|
||||
let queryAction: QueryTaskbarAction = new RunQueryAction(undefined, undefined, undefined);
|
||||
|
||||
// "class should automatically get set to include the base class and the RunQueryAction class
|
||||
let className = RunQueryAction.EnabledClass;
|
||||
assert.equal(queryAction.class, className, 'CSS class not properly set');
|
||||
done();
|
||||
});
|
||||
|
||||
test('getConnectedQueryEditorUri returns connected URI only if connected', (done) => {
|
||||
test('getConnectedQueryEditorUri returns connected URI only if connected', () => {
|
||||
// ... Create assert variables
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
|
||||
@@ -114,10 +113,9 @@ suite('SQL QueryAction Tests', () => {
|
||||
|
||||
// I should get a connected state
|
||||
assert(connected, 'Connected editor should get back a non-undefined URI');
|
||||
done();
|
||||
});
|
||||
|
||||
test('RunQueryAction calls runQuery() only if URI is connected', (done) => {
|
||||
test('RunQueryAction calls runQuery() only if URI is connected', async () => {
|
||||
// ... Create assert variables
|
||||
let isConnected: boolean = undefined;
|
||||
let connectionParams: INewConnectionParams = undefined;
|
||||
@@ -141,7 +139,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
let queryAction: RunQueryAction = new RunQueryAction(editor.object, queryModelService.object, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
calledRunQueryOnInput = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// runQuery should not be run
|
||||
assert.equal(calledRunQueryOnInput, false, 'run should not call runQuery');
|
||||
@@ -155,17 +153,16 @@ suite('SQL QueryAction Tests', () => {
|
||||
|
||||
// If I call run on RunQueryAction when I am connected
|
||||
isConnected = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
//runQuery should be run, and the conneciton dialog should not open
|
||||
assert.equal(calledRunQueryOnInput, true, 'run should call runQuery');
|
||||
testQueryInput.verify(x => x.runQuery(undefined), TypeMoq.Times.once());
|
||||
|
||||
assert.equal(countCalledShowDialog, 1, 'run should not call showDialog');
|
||||
done();
|
||||
});
|
||||
|
||||
test('Queries are only run if the QueryEditor selection is not empty', (done) => {
|
||||
test('Queries are only run if the QueryEditor selection is not empty', async () => {
|
||||
// ... Create assert variables
|
||||
let isSelectionEmpty: boolean = undefined;
|
||||
let countCalledRunQuery: number = 0;
|
||||
@@ -199,21 +196,20 @@ suite('SQL QueryAction Tests', () => {
|
||||
// If I call run on RunQueryAction when I have a non empty selection
|
||||
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, queryModelService.object, connectionManagementService.object);
|
||||
isSelectionEmpty = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
//runQuery should be run
|
||||
assert.equal(countCalledRunQuery, 1, 'runQuery should be called');
|
||||
|
||||
// If I call run on RunQueryAction when I have an empty selection
|
||||
isSelectionEmpty = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
//runQuery should not be run again
|
||||
assert.equal(countCalledRunQuery, 1, 'runQuery should not be called again');
|
||||
done();
|
||||
});
|
||||
|
||||
test('ISelectionData is properly passed when queries are run', () => {
|
||||
test('ISelectionData is properly passed when queries are run', async () => {
|
||||
|
||||
/// Setup Test ///
|
||||
|
||||
@@ -269,7 +265,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, undefined, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
selectionToReturnInGetSelection = undefined;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The conneciton dialog should open with an undefined seleciton
|
||||
assert.equal(countCalledShowDialog, 1, 'run should call showDialog');
|
||||
@@ -280,7 +276,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
////// If I call run on RunQueryAction while disconnected and with a defined selection
|
||||
isConnected = false;
|
||||
selectionToReturnInGetSelection = predefinedSelection;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The conneciton dialog should open with the correct seleciton
|
||||
assert.equal(countCalledShowDialog, 2, 'run should call showDialog again');
|
||||
@@ -295,7 +291,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
////// If I call run on RunQueryAction while connected and with an undefined selection
|
||||
isConnected = true;
|
||||
selectionToReturnInGetSelection = undefined;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The query should run with an undefined selection
|
||||
assert.equal(countCalledShowDialog, 2, 'run should not call showDialog');
|
||||
@@ -305,7 +301,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
////// If I call run on RunQueryAction while connected and with a defined selection
|
||||
isConnected = true;
|
||||
selectionToReturnInGetSelection = predefinedSelection;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The query should run with the given seleciton
|
||||
assert.equal(countCalledShowDialog, 2, 'run should not call showDialog');
|
||||
@@ -317,7 +313,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
assert.equal(runQuerySelection.endColumn, selectionToReturnInGetSelection.endColumn, 'endColumn should match');
|
||||
});
|
||||
|
||||
test('CancelQueryAction calls cancelQuery() only if URI is connected', (done) => {
|
||||
test('CancelQueryAction calls cancelQuery() only if URI is connected', async () => {
|
||||
// ... Create assert variables
|
||||
let isConnected: boolean = undefined;
|
||||
let calledCancelQuery: boolean = false;
|
||||
@@ -334,22 +330,21 @@ suite('SQL QueryAction Tests', () => {
|
||||
// If I call run on CancelQueryAction when I am not connected
|
||||
let queryAction: CancelQueryAction = new CancelQueryAction(editor.object, queryModelService.object, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// cancelQuery should not be run
|
||||
assert.equal(calledCancelQuery, false, 'run should not call cancelQuery');
|
||||
|
||||
// If I call run on CancelQueryAction when I am connected
|
||||
isConnected = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// cancelQuery should be run
|
||||
assert.equal(calledCancelQuery, true, 'run should call cancelQuery');
|
||||
done();
|
||||
});
|
||||
|
||||
// We want to call disconnectEditor regardless of connection to be able to cancel in-progress connections
|
||||
test('DisconnectDatabaseAction calls disconnectEditor regardless of URI being connected', (done) => {
|
||||
test('DisconnectDatabaseAction calls disconnectEditor regardless of URI being connected', async () => {
|
||||
// ... Create assert variables
|
||||
let isConnected: boolean = undefined;
|
||||
let countCalledDisconnectEditor: number = 0;
|
||||
@@ -363,21 +358,20 @@ suite('SQL QueryAction Tests', () => {
|
||||
// If I call run on DisconnectDatabaseAction when I am not connected
|
||||
let queryAction: DisconnectDatabaseAction = new DisconnectDatabaseAction(editor.object, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// disconnectEditor should be run
|
||||
assert.equal(countCalledDisconnectEditor, 1, 'disconnectEditor should be called when URI is not connected');
|
||||
|
||||
// If I call run on DisconnectDatabaseAction when I am connected
|
||||
isConnected = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// disconnectEditor should be run again
|
||||
assert.equal(countCalledDisconnectEditor, 2, 'disconnectEditor should be called when URI is connected');
|
||||
done();
|
||||
});
|
||||
|
||||
test('ConnectDatabaseAction opens dialog regardless of URI connection state', (done) => {
|
||||
test('ConnectDatabaseAction opens dialog regardless of URI connection state', async () => {
|
||||
// ... Create assert variables
|
||||
let isConnected: boolean = undefined;
|
||||
let connectionParams: INewConnectionParams = undefined;
|
||||
@@ -395,7 +389,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
// If I call run on ConnectDatabaseAction when I am not connected
|
||||
let queryAction: ConnectDatabaseAction = new ConnectDatabaseAction(editor.object, false, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The conneciton dialog should open with the correct parameter details
|
||||
assert.equal(countCalledShowDialog, 1, 'run should call showDialog');
|
||||
@@ -406,7 +400,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
|
||||
// If I call run on ConnectDatabaseAction when I am connected
|
||||
isConnected = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The conneciton dialog should open again with the correct parameter details
|
||||
assert.equal(countCalledShowDialog, 2, 'run should call showDialog');
|
||||
@@ -414,10 +408,9 @@ suite('SQL QueryAction Tests', () => {
|
||||
assert.equal(connectionParams.runQueryOnCompletion, false, 'runQueryOnCompletion should be false`');
|
||||
assert.equal(connectionParams.input.uri, testUri, 'URI should be set to the test URI');
|
||||
assert.equal(connectionParams.input, editor.object.input, 'Editor should be set to the mock editor');
|
||||
done();
|
||||
});
|
||||
|
||||
test('ChangeConnectionAction connects regardless of URI being connected', (done) => {
|
||||
test('ChangeConnectionAction connects regardless of URI being connected', async () => {
|
||||
// ... Create assert variables
|
||||
let queryAction: ConnectDatabaseAction = undefined;
|
||||
let isConnected: boolean = undefined;
|
||||
@@ -435,7 +428,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
// If I call run on ChangeConnectionAction when I am not connected
|
||||
queryAction = new ConnectDatabaseAction(editor.object, false, connectionManagementService.object);
|
||||
isConnected = false;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The connection dialog should open with the params set as below
|
||||
assert.equal(calledShowDialog, 1, 'showDialog should be called when URI is connected');
|
||||
@@ -445,7 +438,7 @@ suite('SQL QueryAction Tests', () => {
|
||||
assert.equal(connectionParams.input, editor.object.input, 'Editor should be set to the mock editor');
|
||||
// Then if I call run on ChangeConnectionAction when I am connected
|
||||
isConnected = true;
|
||||
queryAction.run();
|
||||
await queryAction.run();
|
||||
|
||||
// The conneciton dialog should open with the params set as below
|
||||
assert.equal(calledShowDialog, 2, 'showDialog should be called when URI is connected');
|
||||
@@ -453,10 +446,9 @@ suite('SQL QueryAction Tests', () => {
|
||||
assert.equal(connectionParams.runQueryOnCompletion, false, 'runQueryOnCompletion should be false`');
|
||||
assert.equal(connectionParams.input.uri, testUri, 'URI should be set to the test URI');
|
||||
assert.equal(connectionParams.input, editor.object.input, 'Editor should be set to the mock editor');
|
||||
done();
|
||||
});
|
||||
|
||||
test('ListDatabaseItem shows items as expected', (done) => {
|
||||
test('ListDatabaseItem shows items as expected', () => {
|
||||
// ... Create assert variables
|
||||
let listItem: ListDatabasesActionItem = undefined;
|
||||
let isConnected: boolean = undefined;
|
||||
@@ -488,8 +480,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
listItem.onDisconnect();
|
||||
assert.equal(listItem.isEnabled(), false, 'do not expect dropdown enabled unless connected');
|
||||
assert.equal(listItem.currentDatabaseName, undefined, 'do not expect dropdown to have entries unless connected');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('ListDatabaseItem - null event params', () => {
|
||||
|
||||
Reference in New Issue
Block a user