mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 12:08:36 -05:00
Add more to strict nulls (#11871)
* add more to strict nulls * maintain error handling properly * fix lint
This commit is contained in:
@@ -118,10 +118,11 @@ suite('Account Management Service Tests:', () => {
|
||||
state.mockAccountStore.verify(x => x.addOrUpdate(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
|
||||
// ... The account list was updated
|
||||
state.eventVerifierUpdate.assertFiredWithVerify((params: UpdateAccountListEventParams) => {
|
||||
assert.equal(params.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(params.accountList));
|
||||
assert.equal(params.accountList.length, 1);
|
||||
state.eventVerifierUpdate.assertFiredWithVerify((params: UpdateAccountListEventParams | undefined) => {
|
||||
assert.ok(params);
|
||||
assert.equal(params!.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(params!.accountList));
|
||||
assert.equal(params!.accountList.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -157,10 +158,11 @@ suite('Account Management Service Tests:', () => {
|
||||
|
||||
// ... The account list change should have been fired
|
||||
state.eventVerifierUpdate.assertFiredWithVerify(param => {
|
||||
assert.equal(param.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(param.accountList));
|
||||
assert.equal(param.accountList.length, 1);
|
||||
assert.equal(param.accountList[0], account);
|
||||
assert.ok(param);
|
||||
assert.equal(param!.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(param!.accountList));
|
||||
assert.equal(param!.accountList.length, 1);
|
||||
assert.equal(param!.accountList[0], account);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -196,10 +198,11 @@ suite('Account Management Service Tests:', () => {
|
||||
|
||||
// ... The account list change should have been fired
|
||||
state.eventVerifierUpdate.assertFiredWithVerify(param => {
|
||||
assert.equal(param.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(param.accountList));
|
||||
assert.equal(param.accountList.length, 1);
|
||||
assert.equal(param.accountList[0], account);
|
||||
assert.ok(param);
|
||||
assert.equal(param!.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(param!.accountList));
|
||||
assert.equal(param!.accountList.length, 1);
|
||||
assert.equal(param!.accountList[0], account);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -246,7 +249,7 @@ suite('Account Management Service Tests:', () => {
|
||||
let state = getTestState();
|
||||
state.accountManagementService._providers[noAccountProvider.id] = {
|
||||
accounts: [],
|
||||
provider: null, // Doesn't matter
|
||||
provider: undefined!, // Doesn't matter
|
||||
metadata: noAccountProvider
|
||||
};
|
||||
|
||||
@@ -290,7 +293,7 @@ suite('Account Management Service Tests:', () => {
|
||||
let ams = getTestState().accountManagementService;
|
||||
ams._providers[noAccountProvider.id] = {
|
||||
accounts: [],
|
||||
provider: null, // Doesn't matter
|
||||
provider: undefined!, // Doesn't matter
|
||||
metadata: noAccountProvider
|
||||
};
|
||||
|
||||
@@ -308,7 +311,7 @@ suite('Account Management Service Tests:', () => {
|
||||
let ams = getTestState().accountManagementService;
|
||||
ams._providers[hasAccountProvider.id] = {
|
||||
accounts: [account],
|
||||
provider: null, // Doesn't matter
|
||||
provider: undefined!, // Doesn't matter
|
||||
metadata: hasAccountProvider
|
||||
};
|
||||
|
||||
@@ -350,10 +353,11 @@ suite('Account Management Service Tests:', () => {
|
||||
mockProvider.verify(x => x.clear(TypeMoq.It.isValue(account.key)), TypeMoq.Times.once());
|
||||
|
||||
// ... The updated account list event should have fired
|
||||
state.eventVerifierUpdate.assertFiredWithVerify((params: UpdateAccountListEventParams) => {
|
||||
assert.equal(params.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(params.accountList));
|
||||
assert.equal(params.accountList.length, 0);
|
||||
state.eventVerifierUpdate.assertFiredWithVerify((params: UpdateAccountListEventParams | undefined) => {
|
||||
assert.ok(params);
|
||||
assert.equal(params!.providerId, hasAccountProvider.id);
|
||||
assert.ok(Array.isArray(params!.accountList));
|
||||
assert.equal(params!.accountList.length, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -404,7 +408,7 @@ suite('Account Management Service Tests:', () => {
|
||||
mockDialogController.setup(x => x.openAccountDialog());
|
||||
mockDialogController.setup(x => x.accountDialog).returns(() => <AccountDialog>mockAccountDialog);
|
||||
let mockAccountDialogCloseEvent = new Emitter<void>();
|
||||
mockAccountDialog['onCloseEvent'] = mockAccountDialogCloseEvent.event;
|
||||
(mockAccountDialog as any).onCloseEvent = mockAccountDialogCloseEvent.event;
|
||||
setTimeout(() => {
|
||||
mockAccountDialogCloseEvent.fire();
|
||||
}, 1000);
|
||||
@@ -434,7 +438,7 @@ suite('Account Management Service Tests:', () => {
|
||||
mockDialogController.setup(x => x.openAccountDialog());
|
||||
mockDialogController.setup(x => x.accountDialog).returns(() => <AccountDialog>mockAccountDialog);
|
||||
let mockAccountDialogCloseEvent = new Emitter<void>();
|
||||
mockAccountDialog['onCloseEvent'] = mockAccountDialogCloseEvent.event;
|
||||
(mockAccountDialog as any).onCloseEvent = mockAccountDialogCloseEvent.event;
|
||||
setTimeout(() => {
|
||||
mockAccountDialogCloseEvent.fire();
|
||||
}, 1000);
|
||||
@@ -468,7 +472,7 @@ suite('Account Management Service Tests:', () => {
|
||||
// ... Create ams, account store that will accept account add/update
|
||||
let mocks = getTestState();
|
||||
mocks.mockAccountStore.setup(x => x.addOrUpdate(TypeMoq.It.isAny()))
|
||||
.returns(() => Promise.resolve(undefined));
|
||||
.returns(() => Promise.resolve(undefined!));
|
||||
|
||||
// ... Create mock account provider
|
||||
let mockProvider = getMockAccountProvider();
|
||||
@@ -484,10 +488,11 @@ suite('Account Management Service Tests:', () => {
|
||||
mockProvider.verify(x => x.initialize(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
|
||||
// ... The provider added event should have fired
|
||||
mocks.eventVerifierProviderAdded.assertFiredWithVerify((param: AccountProviderAddedEventParams) => {
|
||||
assert.equal(param.addedProvider, noAccountProvider);
|
||||
assert.ok(Array.isArray(param.initialAccounts));
|
||||
assert.equal(param.initialAccounts.length, 0);
|
||||
mocks.eventVerifierProviderAdded.assertFiredWithVerify((param: AccountProviderAddedEventParams | undefined) => {
|
||||
assert.ok(param);
|
||||
assert.equal(param!.addedProvider, noAccountProvider);
|
||||
assert.ok(Array.isArray(param!.initialAccounts));
|
||||
assert.equal(param!.initialAccounts.length, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -530,7 +535,7 @@ function getTestState(): AccountManagementState {
|
||||
const testNotificationService = new TestNotificationService();
|
||||
|
||||
// Create the account management service
|
||||
let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), null, null, undefined, testNotificationService);
|
||||
let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), undefined!, undefined!, undefined!, testNotificationService);
|
||||
|
||||
// Wire up event handlers
|
||||
let evUpdate = new EventVerifierSingle<UpdateAccountListEventParams>();
|
||||
|
||||
@@ -79,7 +79,7 @@ suite('Account picker service tests', () => {
|
||||
properties: [],
|
||||
isStale: false
|
||||
};
|
||||
let evOnAccountSelectionChangeEvent = new EventVerifierSingle<azdata.Account>();
|
||||
let evOnAccountSelectionChangeEvent = new EventVerifierSingle<azdata.Account | undefined>();
|
||||
service.onAccountSelectionChangeEvent(evOnAccountSelectionChangeEvent.eventHandler);
|
||||
mockOnAccountSelectionChangeEvent.fire(account);
|
||||
evOnAccountSelectionChangeEvent.assertFired(account);
|
||||
|
||||
Reference in New Issue
Block a user