mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -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:
@@ -7,6 +7,7 @@ import * as azdata from 'azdata';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* View model for account dialog
|
||||
@@ -57,7 +58,7 @@ export class AccountViewModel {
|
||||
},
|
||||
() => { /* Swallow failures at getting accounts, we'll just hide that provider */ });
|
||||
});
|
||||
return Promise.all(promises);
|
||||
return Promise.all(promises).then(accounts => coalesce(accounts));
|
||||
}, () => {
|
||||
/* Swallow failures and just pretend we don't have any providers */
|
||||
return [];
|
||||
|
||||
@@ -71,14 +71,14 @@ suite('Account picker view model tests', () => {
|
||||
evUpdateAccounts.assertFired(argUpdateAccounts);
|
||||
});
|
||||
|
||||
test('Initialize - Success', done => {
|
||||
test('Initialize - Success', () => {
|
||||
// Setup: Create a viewmodel with event handlers
|
||||
let mockAccountManagementService = getMockAccountManagementService(true, true);
|
||||
let evUpdateAccounts = new EventVerifierSingle<UpdateAccountListEventParams>();
|
||||
let vm = getViewModel(mockAccountManagementService.object, evUpdateAccounts);
|
||||
|
||||
// If: I initialize the view model
|
||||
vm.initialize()
|
||||
return vm.initialize()
|
||||
.then(results => {
|
||||
// Then:
|
||||
// ... None of the events should have fired
|
||||
@@ -91,20 +91,17 @@ suite('Account picker view model tests', () => {
|
||||
assert.ok(Array.isArray(results));
|
||||
assert.equal(results.length, 2);
|
||||
assert.equal(results, accounts);
|
||||
}).then(
|
||||
() => done(),
|
||||
err => done(err)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Initialize - Get accounts fails expects empty array', done => {
|
||||
test('Initialize - Get accounts fails expects empty array', () => {
|
||||
// Setup: Create a mock account management service that rejects the promise
|
||||
let mockAccountManagementService = getMockAccountManagementService(true, false);
|
||||
let evUpdateAccounts = new EventVerifierSingle<UpdateAccountListEventParams>();
|
||||
let vm = getViewModel(mockAccountManagementService.object, evUpdateAccounts);
|
||||
|
||||
// If: I initialize the view model
|
||||
vm.initialize()
|
||||
return vm.initialize()
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... None of the events should have fired
|
||||
@@ -116,11 +113,7 @@ suite('Account picker view model tests', () => {
|
||||
// ... The results should be an empty array
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 0);
|
||||
assert.equal(result, []);
|
||||
}).then(
|
||||
() => done(),
|
||||
err => done()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ import AccountStore from 'sql/platform/accounts/common/accountStore';
|
||||
import { EventVerifierSingle } from 'sql/base/test/common/event';
|
||||
|
||||
suite('Account Store Tests', () => {
|
||||
test('AddOrUpdate - Uninitialized memento', done => {
|
||||
test('AddOrUpdate - Uninitialized memento', () => {
|
||||
// Setup: Create account store w/o initialized memento
|
||||
let memento = {};
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I add an account to the store
|
||||
as.addOrUpdate(account1)
|
||||
return as.addOrUpdate(account1)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should have gotten back a result indicating the account was added
|
||||
@@ -27,21 +27,17 @@ suite('Account Store Tests', () => {
|
||||
assert.ok(Array.isArray(memento[AccountStore.MEMENTO_KEY]));
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 1);
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][0], account1);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('AddOrUpdate - Adds to accounts', done => {
|
||||
test('AddOrUpdate - Adds to accounts', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = {};
|
||||
memento[AccountStore.MEMENTO_KEY] = [];
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I add an account to the store
|
||||
as.addOrUpdate(account1)
|
||||
return as.addOrUpdate(account1)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should have gotten back a result indicating the account was added
|
||||
@@ -53,14 +49,10 @@ suite('Account Store Tests', () => {
|
||||
assert.ok(Array.isArray(memento[AccountStore.MEMENTO_KEY]));
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 1);
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][0], account1);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('AddOrUpdate - Updates account', done => {
|
||||
test('AddOrUpdate - Updates account', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
@@ -71,7 +63,7 @@ suite('Account Store Tests', () => {
|
||||
displayInfo: account1.displayInfo,
|
||||
isStale: account1.isStale
|
||||
};
|
||||
as.addOrUpdate(param)
|
||||
return as.addOrUpdate(param)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should have gotten back a result indicating the account was updated
|
||||
@@ -84,20 +76,16 @@ suite('Account Store Tests', () => {
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 2);
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][0], account1);
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][1], param);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAccountsByProvider - Uninitialized memento', done => {
|
||||
test('GetAccountsByProvider - Uninitialized memento', () => {
|
||||
// Setup: Create account store w/o initialized memento
|
||||
let memento = {};
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts by provider
|
||||
as.getAccountsByProvider('azure')
|
||||
return as.getAccountsByProvider('azure')
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back an empty array
|
||||
@@ -106,77 +94,61 @@ suite('Account Store Tests', () => {
|
||||
|
||||
// ... Memento should not have been written
|
||||
assert.equal(Object.keys(memento).length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAccountsByProvider - No accounts', done => {
|
||||
test('GetAccountsByProvider - No accounts', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = {};
|
||||
memento[AccountStore.MEMENTO_KEY] = [];
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts when there aren't any accounts
|
||||
as.getAccountsByProvider('azure')
|
||||
return as.getAccountsByProvider('azure')
|
||||
.then(result => {
|
||||
// Then: I should get back an empty array
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAccountsByProvider - Accounts, but no accounts for provider', done => {
|
||||
test('GetAccountsByProvider - Accounts, but no accounts for provider', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts by provider that doesn't have accounts
|
||||
as.getAccountsByProvider('cloudycloud')
|
||||
return as.getAccountsByProvider('cloudycloud')
|
||||
.then(result => {
|
||||
// Then: I should get back an empty array
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAccountsByProvider - Accounts for provider', done => {
|
||||
test('GetAccountsByProvider - Accounts for provider', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts by provider that has accounts
|
||||
as.getAccountsByProvider('azure')
|
||||
return as.getAccountsByProvider('azure')
|
||||
.then(result => {
|
||||
// Then: I should get the accounts
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 2);
|
||||
assertAccountEqual(result[0], memento[AccountStore.MEMENTO_KEY][0]);
|
||||
assertAccountEqual(result[1], memento[AccountStore.MEMENTO_KEY][1]);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAllAccounts - Uninitialized memento', done => {
|
||||
test('GetAllAccounts - Uninitialized memento', () => {
|
||||
// Setup: Create account store w/o initialized memento
|
||||
let memento = {};
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts
|
||||
as.getAllAccounts()
|
||||
return as.getAllAccounts()
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back an empty array
|
||||
@@ -185,59 +157,47 @@ suite('Account Store Tests', () => {
|
||||
|
||||
// ... Memento should not have been written
|
||||
assert.equal(Object.keys(memento).length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAllAccounts - No accounts', done => {
|
||||
test('GetAllAccounts - No accounts', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = {};
|
||||
memento[AccountStore.MEMENTO_KEY] = [];
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts when there aren't any accounts
|
||||
as.getAllAccounts()
|
||||
return as.getAllAccounts()
|
||||
.then(result => {
|
||||
// Then: I should get back an empty array
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('GetAllAccounts - Accounts', done => {
|
||||
test('GetAllAccounts - Accounts', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I get accounts
|
||||
as.getAllAccounts()
|
||||
return as.getAllAccounts()
|
||||
.then(result => {
|
||||
// Then: I should get the accounts
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.equal(result.length, 2);
|
||||
assertAccountEqual(result[0], memento[AccountStore.MEMENTO_KEY][0]);
|
||||
assertAccountEqual(result[1], memento[AccountStore.MEMENTO_KEY][1]);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Remove - Uninitialized menento', done => {
|
||||
test('Remove - Uninitialized menento', () => {
|
||||
// Setup: Create account store w/o initialized memento
|
||||
let memento = {};
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I remove an account when there's an uninitialized memento
|
||||
as.remove(account1.key)
|
||||
return as.remove(account1.key)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back false (no account removed)
|
||||
@@ -246,21 +206,17 @@ suite('Account Store Tests', () => {
|
||||
// ... The memento should have been initialized
|
||||
assert.ok(Array.isArray(memento[AccountStore.MEMENTO_KEY]));
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Remove - Account does not exist', done => {
|
||||
test('Remove - Account does not exist', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = {};
|
||||
memento[AccountStore.MEMENTO_KEY] = [];
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I remove an account that doesn't exist
|
||||
as.remove({ providerId: 'cloudyCloud', accountId: 'testyTest' })
|
||||
return as.remove({ providerId: 'cloudyCloud', accountId: 'testyTest' })
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back false (no account removed)
|
||||
@@ -269,20 +225,16 @@ suite('Account Store Tests', () => {
|
||||
// ... The memento should still be empty
|
||||
assert.ok(Array.isArray(memento[AccountStore.MEMENTO_KEY]));
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Remove - Account exists', done => {
|
||||
test('Remove - Account exists', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
|
||||
// If: I remove an account that does exist
|
||||
as.remove(account1.key)
|
||||
return as.remove(account1.key)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back true (account removed)
|
||||
@@ -292,14 +244,10 @@ suite('Account Store Tests', () => {
|
||||
assert.ok(Array.isArray(memento[AccountStore.MEMENTO_KEY]));
|
||||
assert.equal(memento[AccountStore.MEMENTO_KEY].length, 1);
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][0], account2);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Update - Uninitialized menento', done => {
|
||||
test('Update - Uninitialized menento', () => {
|
||||
// Setup:
|
||||
// ... Create account store w/o initialized memento
|
||||
let memento = {};
|
||||
@@ -309,7 +257,7 @@ suite('Account Store Tests', () => {
|
||||
let updateCallback = new EventVerifierSingle<azdata.Account>();
|
||||
|
||||
// If: I update an account
|
||||
as.update(account1.key, updateCallback.eventHandler)
|
||||
return as.update(account1.key, updateCallback.eventHandler)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back false (account did not change)
|
||||
@@ -321,14 +269,10 @@ suite('Account Store Tests', () => {
|
||||
|
||||
// ... The callback shouldn't have been called
|
||||
updateCallback.assertNotFired();
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Update - Account does not exist', done => {
|
||||
test('Update - Account does not exist', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = {};
|
||||
memento[AccountStore.MEMENTO_KEY] = [];
|
||||
@@ -338,7 +282,7 @@ suite('Account Store Tests', () => {
|
||||
let updateCallback = new EventVerifierSingle<azdata.Account>();
|
||||
|
||||
// If: I update an account that doesn't exist
|
||||
as.update({ accountId: 'testyTest', providerId: 'cloudyCloud' }, updateCallback.eventHandler)
|
||||
return as.update({ accountId: 'testyTest', providerId: 'cloudyCloud' }, updateCallback.eventHandler)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back false (account did not change)
|
||||
@@ -350,14 +294,10 @@ suite('Account Store Tests', () => {
|
||||
|
||||
// ... The callback shouldn't have been called
|
||||
updateCallback.assertNotFired();
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Update - Account exists', done => {
|
||||
test('Update - Account exists', () => {
|
||||
// Setup: Create account store with initialized memento with accounts
|
||||
let memento = getTestMemento();
|
||||
let as = new AccountStore(memento);
|
||||
@@ -369,7 +309,7 @@ suite('Account Store Tests', () => {
|
||||
};
|
||||
|
||||
// If: I update an account that exists
|
||||
as.update(account1.key, updateCallback)
|
||||
return as.update(account1.key, updateCallback)
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... I should get back true (account did change)
|
||||
@@ -384,11 +324,7 @@ suite('Account Store Tests', () => {
|
||||
|
||||
// ... Account 2 should have stayed the same
|
||||
assertAccountEqual(memento[AccountStore.MEMENTO_KEY][1], account2);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
e => done(e)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Test to make sure operations occur sequentially
|
||||
|
||||
@@ -91,7 +91,7 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
evUpdateAccounts.assertFired(argUpdateAccounts);
|
||||
});
|
||||
|
||||
test('Initialize - Success', done => {
|
||||
test('Initialize - Success', () => {
|
||||
// Setup: Create a viewmodel with event handlers
|
||||
let mockAccountManagementService = getMockAccountManagementService(true, true);
|
||||
let evAddProvider = new EventVerifierSingle<AccountProviderAddedEventParams>();
|
||||
@@ -100,7 +100,7 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
let vm = getViewModel(mockAccountManagementService.object, evAddProvider, evRemoveProvider, evUpdateAccounts);
|
||||
|
||||
// If: I initialize the view model
|
||||
vm.initialize()
|
||||
return vm.initialize()
|
||||
.then(results => {
|
||||
// Then:
|
||||
// ... None of the events should have fired
|
||||
@@ -115,13 +115,10 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
assert.equal(results.length, 1);
|
||||
assert.equal(results[0].addedProvider, providers[0]);
|
||||
assert.equal(results[0].initialAccounts, accounts);
|
||||
}).then(
|
||||
() => done(),
|
||||
err => done(err)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Initialize - Get providers fails', done => {
|
||||
test('Initialize - Get providers fails', () => {
|
||||
// Setup: Create a mock account management service that rejects looking up providers
|
||||
let mockAccountManagementService = getMockAccountManagementService(false, true);
|
||||
let evAddProvider = new EventVerifierSingle<AccountProviderAddedEventParams>();
|
||||
@@ -130,7 +127,7 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
let vm = getViewModel(mockAccountManagementService.object, evAddProvider, evRemoveProvider, evUpdateAccounts);
|
||||
|
||||
// If: I initialize the view model
|
||||
vm.initialize()
|
||||
return vm.initialize()
|
||||
.then(results => {
|
||||
// Then
|
||||
// ... None of the events should have fired
|
||||
@@ -143,14 +140,10 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
// ... The results that were returned should be an empty array
|
||||
assert.ok(Array.isArray(results));
|
||||
assert.equal(results.length, 0);
|
||||
})
|
||||
.then(
|
||||
() => done(),
|
||||
err => done(err)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Initialize - Get accounts fails', done => {
|
||||
test.skip('Initialize - Get accounts fails', () => { // @anthonydresser I don't understand this test, it says get accounts fails, but then assumes there will be accounts in the results...
|
||||
// Setup: Create a mock account management service that rejects the promise
|
||||
let mockAccountManagementService = getMockAccountManagementService(true, false);
|
||||
let evAddProvider = new EventVerifierSingle<AccountProviderAddedEventParams>();
|
||||
@@ -159,7 +152,7 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
let vm = getViewModel(mockAccountManagementService.object, evAddProvider, evRemoveProvider, evUpdateAccounts);
|
||||
|
||||
// If: I initialize the view model
|
||||
vm.initialize()
|
||||
return vm.initialize()
|
||||
.then(result => {
|
||||
// Then:
|
||||
// ... None of the events should have fired
|
||||
@@ -174,10 +167,7 @@ suite('Account Management Dialog ViewModel Tests', () => {
|
||||
assert.equal(result.length, 1);
|
||||
assert.equal(result[0].addedProvider, providers[0]);
|
||||
assert.equal(result[0].initialAccounts, accounts);
|
||||
}).then(
|
||||
() => done(),
|
||||
err => done()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export class TestCredentialsService implements ICredentialsService {
|
||||
}
|
||||
|
||||
addEventListener(handle: number, events: CredentialManagementEvents): IDisposable {
|
||||
throw new Error('Method not implemented.');
|
||||
return { dispose: () => { } };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,9 +74,13 @@ suite('Job Management Actions', () => {
|
||||
errorMessage: null
|
||||
};
|
||||
mockJobManagementService.setup(s => s.jobAction(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(resultStatus));
|
||||
mockJobManagementService.setup(s => s.deleteJobStep(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(resultStatus));
|
||||
mockJobManagementService.setup(s => s.deleteProxy(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(resultStatus));
|
||||
mockJobManagementService.setup(s => s.deleteOperator(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(resultStatus));
|
||||
mockJobManagementService.setup(s => s.deleteAlert(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(resultStatus));
|
||||
});
|
||||
|
||||
test('Jobs Refresh Action', (done) => {
|
||||
test('Jobs Refresh Action', async () => {
|
||||
mockRefreshAction = TypeMoq.Mock.ofType(JobsRefreshAction, TypeMoq.MockBehavior.Strict, JobsRefreshAction.ID, JobsRefreshAction.LABEL);
|
||||
mockRefreshAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => mockJobsViewComponent.object.refreshJobs());
|
||||
mockRefreshAction.setup(s => s.id).returns(() => JobsRefreshAction.ID);
|
||||
@@ -85,12 +89,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockRefreshAction.object.label, JobsRefreshAction.LABEL);
|
||||
|
||||
// Job Refresh Action from Jobs View should refresh the component
|
||||
mockRefreshAction.object.run(null);
|
||||
await mockRefreshAction.object.run(null);
|
||||
mockJobsViewComponent.verify(c => c.refreshJobs(), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('New Job Action', (done) => {
|
||||
test('New Job Action', async () => {
|
||||
mockNewJobAction = TypeMoq.Mock.ofType(NewJobAction, TypeMoq.MockBehavior.Strict, NewJobAction.ID, NewJobAction.LABEL);
|
||||
mockNewJobAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => mockJobsViewComponent.object.openCreateJobDialog());
|
||||
mockNewJobAction.setup(s => s.id).returns(() => NewJobAction.ID);
|
||||
@@ -99,12 +102,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockNewJobAction.object.label, NewJobAction.LABEL);
|
||||
|
||||
// New Job Action from Jobs View should open a dialog
|
||||
mockNewJobAction.object.run(null);
|
||||
await mockNewJobAction.object.run(null);
|
||||
mockJobsViewComponent.verify(c => c.openCreateJobDialog(), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Edit Job Action', (done) => {
|
||||
test('Edit Job Action', async () => {
|
||||
mockEditJobAction = TypeMoq.Mock.ofType(EditJobAction, TypeMoq.MockBehavior.Strict, EditJobAction.ID, EditJobAction.LABEL);
|
||||
let commandServiceCalled: boolean = false;
|
||||
mockEditJobAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => {
|
||||
@@ -117,12 +119,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockEditJobAction.object.label, EditJobAction.LABEL);
|
||||
|
||||
// Edit Job Action from Jobs View should open a dialog
|
||||
mockEditJobAction.object.run(null);
|
||||
await mockEditJobAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Run Job Action', (done) => {
|
||||
test('Run Job Action', async () => {
|
||||
mockRunJobAction = TypeMoq.Mock.ofType(RunJobAction, TypeMoq.MockBehavior.Strict, RunJobAction.ID, RunJobAction.LABEL, null, null, mockJobManagementService);
|
||||
mockRunJobAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
let result = await mockJobManagementService.object.jobAction(null, null, null).then((result) => result.success);
|
||||
@@ -135,12 +136,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockRunJobAction.object.label, RunJobAction.LABEL);
|
||||
|
||||
// Run Job Action should make the Job Management service call job action
|
||||
mockRunJobAction.object.run(null);
|
||||
await mockRunJobAction.object.run(null);
|
||||
mockJobManagementService.verify(s => s.jobAction(null, null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Stop Job Action', (done) => {
|
||||
test('Stop Job Action', async () => {
|
||||
mockStopJobAction = TypeMoq.Mock.ofType(StopJobAction, TypeMoq.MockBehavior.Strict, StopJobAction.ID, StopJobAction.LABEL, null, null, mockJobManagementService);
|
||||
mockStopJobAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
let result = await mockJobManagementService.object.jobAction(null, null, null).then((result) => result.success);
|
||||
@@ -153,12 +153,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockStopJobAction.object.label, RunJobAction.LABEL);
|
||||
|
||||
// Run Job Action should make the Job Management service call job action
|
||||
mockStopJobAction.object.run(null);
|
||||
await mockStopJobAction.object.run(null);
|
||||
mockJobManagementService.verify(s => s.jobAction(null, null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Delete Job Action', (done) => {
|
||||
test('Delete Job Action', async () => {
|
||||
mockDeleteJobAction = TypeMoq.Mock.ofType(DeleteJobAction, TypeMoq.MockBehavior.Strict, DeleteJobAction.ID, DeleteJobAction.LABEL, null, null, mockJobManagementService);
|
||||
mockDeleteJobAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
let result = await mockJobManagementService.object.jobAction(null, null, null).then((result) => result.success);
|
||||
@@ -171,13 +170,12 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockDeleteJobAction.object.label, DeleteJobAction.LABEL);
|
||||
|
||||
// Run Job Action should make the Job Management service call job action
|
||||
mockDeleteJobAction.object.run(null);
|
||||
await mockDeleteJobAction.object.run(null);
|
||||
mockJobManagementService.verify(s => s.jobAction(null, null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
// Step Actions
|
||||
test('New Step Action', (done) => {
|
||||
test('New Step Action', async () => {
|
||||
mockNewStepAction = TypeMoq.Mock.ofType(NewStepAction, TypeMoq.MockBehavior.Strict, NewJobAction.ID, NewJobAction.LABEL);
|
||||
let commandServiceCalled = false;
|
||||
mockNewStepAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => {
|
||||
@@ -190,18 +188,17 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockNewStepAction.object.label, NewJobAction.LABEL);
|
||||
|
||||
// New Step Action should called command service
|
||||
mockNewStepAction.object.run(null);
|
||||
await mockNewStepAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Delete Step Action', (done) => {
|
||||
test('Delete Step Action', async () => {
|
||||
mockDeleteStepAction = TypeMoq.Mock.ofType(DeleteStepAction, TypeMoq.MockBehavior.Strict, DeleteStepAction.ID, DeleteStepAction.LABEL);
|
||||
let commandServiceCalled = false;
|
||||
mockDeleteStepAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
commandServiceCalled = true;
|
||||
await mockJobManagementService.object.deleteJobStep(null, null).then((result) => result.success);
|
||||
return Promise.resolve(commandServiceCalled);
|
||||
return commandServiceCalled;
|
||||
});
|
||||
mockDeleteStepAction.setup(s => s.id).returns(() => DeleteStepAction.ID);
|
||||
mockDeleteStepAction.setup(s => s.label).returns(() => DeleteStepAction.LABEL);
|
||||
@@ -209,14 +206,13 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockDeleteStepAction.object.label, DeleteStepAction.LABEL);
|
||||
|
||||
// Delete Step Action should called command service
|
||||
mockDeleteStepAction.object.run(null);
|
||||
await mockDeleteStepAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
mockJobManagementService.verify(s => s.deleteJobStep(null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
// Alert Actions
|
||||
test('New Alert Action', (done) => {
|
||||
test('New Alert Action', async () => {
|
||||
mockNewAlertAction = TypeMoq.Mock.ofType(NewJobAction, TypeMoq.MockBehavior.Strict, NewJobAction.ID, NewJobAction.LABEL);
|
||||
mockNewAlertAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => mockAlertsViewComponent.object.openCreateAlertDialog());
|
||||
mockNewAlertAction.setup(s => s.id).returns(() => NewJobAction.ID);
|
||||
@@ -225,12 +221,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockNewAlertAction.object.label, NewJobAction.LABEL);
|
||||
|
||||
// New Alert Action from Alerts View should open a dialog
|
||||
mockNewAlertAction.object.run(null);
|
||||
await mockNewAlertAction.object.run(null);
|
||||
mockAlertsViewComponent.verify(c => c.openCreateAlertDialog(), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Edit Alert Action', (done) => {
|
||||
test('Edit Alert Action', async () => {
|
||||
mockEditAlertAction = TypeMoq.Mock.ofType(EditAlertAction, TypeMoq.MockBehavior.Strict, EditAlertAction.ID, EditAlertAction.LABEL);
|
||||
let commandServiceCalled: boolean = false;
|
||||
mockEditAlertAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => {
|
||||
@@ -243,12 +238,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockEditAlertAction.object.label, EditAlertAction.LABEL);
|
||||
|
||||
// Edit Alert Action from Jobs View should open a dialog
|
||||
mockEditAlertAction.object.run(null);
|
||||
await mockEditAlertAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Delete Alert Action', (done) => {
|
||||
test('Delete Alert Action', async () => {
|
||||
mockDeleteAlertAction = TypeMoq.Mock.ofType(DeleteAlertAction, TypeMoq.MockBehavior.Strict, DeleteAlertAction.ID, DeleteAlertAction.LABEL, null, null, mockJobManagementService);
|
||||
let commandServiceCalled = false;
|
||||
mockDeleteAlertAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
@@ -262,14 +256,13 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockDeleteAlertAction.object.label, DeleteAlertAction.LABEL);
|
||||
|
||||
// Delete Alert Action should call job management service
|
||||
mockDeleteAlertAction.object.run(null);
|
||||
await mockDeleteAlertAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
mockJobManagementService.verify(s => s.deleteAlert(null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
// Operator Tests
|
||||
test('New Operator Action', (done) => {
|
||||
test('New Operator Action', async () => {
|
||||
mockNewOperatorAction = TypeMoq.Mock.ofType(NewOperatorAction, TypeMoq.MockBehavior.Strict, NewOperatorAction.ID, NewOperatorAction.LABEL);
|
||||
mockNewOperatorAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => mockOperatorsViewComponent.object.openCreateOperatorDialog());
|
||||
mockNewOperatorAction.setup(s => s.id).returns(() => NewOperatorAction.ID);
|
||||
@@ -278,12 +271,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockNewOperatorAction.object.label, NewOperatorAction.LABEL);
|
||||
|
||||
// New Operator Action from Operators View should open a dialog
|
||||
mockNewOperatorAction.object.run(null);
|
||||
await mockNewOperatorAction.object.run(null);
|
||||
mockOperatorsViewComponent.verify(c => c.openCreateOperatorDialog(), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Edit Operator Action', (done) => {
|
||||
test('Edit Operator Action', async () => {
|
||||
mockEditOperatorAction = TypeMoq.Mock.ofType(EditOperatorAction, TypeMoq.MockBehavior.Strict, EditOperatorAction.ID, EditOperatorAction.LABEL);
|
||||
let commandServiceCalled: boolean = false;
|
||||
mockEditOperatorAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => {
|
||||
@@ -296,12 +288,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockEditOperatorAction.object.label, EditOperatorAction.LABEL);
|
||||
|
||||
// Edit Operator Action from Jobs View should open a dialog
|
||||
mockEditOperatorAction.object.run(null);
|
||||
await mockEditOperatorAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Delete Operator Action', (done) => {
|
||||
test('Delete Operator Action', async () => {
|
||||
mockDeleteOperatorAction = TypeMoq.Mock.ofType(DeleteOperatorAction, TypeMoq.MockBehavior.Strict, DeleteOperatorAction.ID, DeleteOperatorAction.LABEL, null, null, mockJobManagementService);
|
||||
let commandServiceCalled = false;
|
||||
mockDeleteOperatorAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
@@ -315,14 +306,13 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockDeleteOperatorAction.object.label, DeleteOperatorAction.LABEL);
|
||||
|
||||
// Delete Operator Action should call job management service
|
||||
mockDeleteOperatorAction.object.run(null);
|
||||
await mockDeleteOperatorAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
mockJobManagementService.verify(s => s.deleteOperator(null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
// Proxy Actions
|
||||
test('New Proxy Action', (done) => {
|
||||
test('New Proxy Action', async () => {
|
||||
mockNewProxyAction = TypeMoq.Mock.ofType(NewProxyAction, TypeMoq.MockBehavior.Strict, NewProxyAction.ID, NewProxyAction.LABEL);
|
||||
mockNewProxyAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => mockProxiesViewComponent.object.openCreateProxyDialog());
|
||||
mockNewProxyAction.setup(s => s.id).returns(() => NewProxyAction.ID);
|
||||
@@ -331,12 +321,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockNewProxyAction.object.label, NewProxyAction.LABEL);
|
||||
|
||||
// New Proxy Action from Alerts View should open a dialog
|
||||
mockNewProxyAction.object.run(null);
|
||||
await mockNewProxyAction.object.run(null);
|
||||
mockProxiesViewComponent.verify(c => c.openCreateProxyDialog(), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
test('Edit Proxy Action', (done) => {
|
||||
test('Edit Proxy Action', async () => {
|
||||
mockEditProxyAction = TypeMoq.Mock.ofType(EditProxyAction, TypeMoq.MockBehavior.Strict, EditProxyAction.ID, EditProxyAction.LABEL);
|
||||
let commandServiceCalled: boolean = false;
|
||||
mockEditProxyAction.setup(s => s.run(TypeMoq.It.isAny())).returns(() => {
|
||||
@@ -349,12 +338,11 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockEditProxyAction.object.label, EditProxyAction.LABEL);
|
||||
|
||||
// Edit Proxy Action from Proxies View should open a dialog
|
||||
mockEditProxyAction.object.run(null);
|
||||
await mockEditProxyAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Delete Proxy Action', (done) => {
|
||||
test('Delete Proxy Action', async () => {
|
||||
mockDeleteProxyAction = TypeMoq.Mock.ofType(DeleteProxyAction, TypeMoq.MockBehavior.Strict, DeleteProxyAction.ID, DeleteProxyAction.LABEL, null, null, mockJobManagementService);
|
||||
let commandServiceCalled = false;
|
||||
mockDeleteProxyAction.setup(s => s.run(TypeMoq.It.isAny())).returns(async () => {
|
||||
@@ -368,10 +356,8 @@ suite('Job Management Actions', () => {
|
||||
assert.equal(mockDeleteProxyAction.object.label, DeleteProxyAction.LABEL);
|
||||
|
||||
// Delete Proxy Action should call job management service
|
||||
mockDeleteProxyAction.object.run(null);
|
||||
await mockDeleteProxyAction.object.run(null);
|
||||
assert(commandServiceCalled);
|
||||
mockJobManagementService.verify(s => s.deleteProxy(null, null), TypeMoq.Times.once());
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user