Strict Null Checks, Builder Removal, Formatting (#4849)

* remove builder; more null checks

* null checks

* formatting

* wip

* fix dropdown themeing

* formatting

* formatting

* fix tests

* update what files are checked

* add code to help refresh bad nodes
This commit is contained in:
Anthony Dresser
2019-04-08 13:27:41 -07:00
committed by GitHub
parent 01784dd186
commit 22ec1d5f0a
57 changed files with 177 additions and 206 deletions

View File

@@ -31,7 +31,7 @@ import { ConfigurationService } from 'vs/platform/configuration/node/configurati
import * as TypeMoq from 'typemoq';
import * as assert from 'assert';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { TestStorageService, TestLayoutService } from 'vs/workbench/test/workbenchTestServices';
let none: void;
@@ -51,7 +51,7 @@ suite('SQL QueryAction Tests', () => {
// Setup a reusable mock QueryEditor
editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService(), undefined, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, new TestStorageService());
undefined, undefined, undefined, new TestStorageService());
editor.setup(x => x.connectedUri).returns(() => testUri);
editor.setup(x => x.currentQueryInput).returns(() => testQueryInput.object);
editor.setup(x => x.uri).returns(() => testUri);
@@ -88,7 +88,7 @@ suite('SQL QueryAction Tests', () => {
// ... Create an editor
let editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService(), undefined, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, new TestStorageService());
undefined, undefined, undefined, new TestStorageService());
editor.setup(x => x.currentQueryInput).returns(() => testQueryInput.object);
// If I create a QueryTaskbarAction and I pass a non-connected editor to _getConnectedQueryEditorUri
@@ -175,7 +175,7 @@ suite('SQL QueryAction Tests', () => {
countCalledRunQuery++;
});
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService(), undefined,
undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object);
queryEditor.setup(x => x.getSelection()).returns(() => undefined);
queryEditor.setup(x => x.getSelection(false)).returns(() => undefined);
@@ -242,7 +242,7 @@ suite('SQL QueryAction Tests', () => {
// ... Mock "getSelection" in QueryEditor
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService(), undefined,
undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object);
queryEditor.setup(x => x.getSelection()).returns(() => {
return selectionToReturnInGetSelection;
@@ -475,8 +475,10 @@ suite('SQL QueryAction Tests', () => {
databaseName: databaseName
});
const layoutService = new TestLayoutService();
// If I query without having initialized anything, state should be clear
listItem = new ListDatabasesActionItem(editor.object, connectionManagementService.object, undefined, undefined, configurationService.object);
listItem = new ListDatabasesActionItem(editor.object, connectionManagementService.object, undefined, undefined, configurationService.object, layoutService);
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');
@@ -510,8 +512,10 @@ suite('SQL QueryAction Tests', () => {
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
const layoutService = new TestLayoutService();
// ... Create a database dropdown that has been connected
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object, layoutService);
listItem.onConnected();
// If: I raise a connection changed event
@@ -534,8 +538,10 @@ suite('SQL QueryAction Tests', () => {
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
const layoutService = new TestLayoutService();
// ... Create a database dropdown that has been connected
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object, layoutService);
listItem.onConnected();
// If: I raise a connection changed event for the 'wrong' URI
@@ -561,8 +567,10 @@ suite('SQL QueryAction Tests', () => {
cms.callBase = true;
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
const layoutService = new TestLayoutService();
// ... Create a database dropdown
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object, layoutService);
// If: I raise a connection changed event
let eventParams = <IConnectionParams>{

View File

@@ -47,7 +47,6 @@ suite('SQL QueryEditor Tests', () => {
instantiationService.object,
undefined,
undefined,
undefined,
editorDescriptorService.object,
undefined,
undefined,
@@ -82,7 +81,7 @@ suite('SQL QueryEditor Tests', () => {
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
if (classDef.ID) {
if (classDef.ID === 'listDatabaseQueryActionItem') {
return new ListDatabasesActionItem(editor, connectionManagementService.object, undefined, undefined, configurationService.object);
return new ListDatabasesActionItem(editor, connectionManagementService.object, undefined, undefined, configurationService.object, undefined);
}
}
// Default
@@ -318,7 +317,7 @@ suite('SQL QueryEditor Tests', () => {
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
.returns((definition, editor, action, selectBox) => {
if (definition.ID === 'listDatabaseQueryActionItem') {
let item = new ListDatabasesActionItem(editor, queryConnectionService.object, undefined, undefined, configurationService.object);
let item = new ListDatabasesActionItem(editor, queryConnectionService.object, undefined, undefined, configurationService.object, undefined);
return item;
}
// Default