Await should() methods involving promises in tests. (#8876)

This commit is contained in:
Cory Rivera
2020-01-15 00:41:23 -08:00
committed by GitHub
parent 74c2d16660
commit d3105beb43
3 changed files with 23 additions and 16 deletions

View File

@@ -109,11 +109,11 @@ describe('Notebook Extension Python Installation', function () {
// the conda utilities should fail. // the conda utilities should fail.
should(install.usingConda).be.false(); should(install.usingConda).be.false();
should(install.getInstalledCondaPackages()).be.rejected(); await should(install.getInstalledCondaPackages()).be.rejected();
should(install.installCondaPackages([{ name: 'pandas', version: '0.24.2' }], false)).be.rejected(); await should(install.installCondaPackages([{ name: 'pandas', version: '0.24.2' }], false)).be.rejected();
should(install.uninstallCondaPackages([{ name: 'pandas', version: '0.24.2' }])).be.rejected(); await should(install.uninstallCondaPackages([{ name: 'pandas', version: '0.24.2' }])).be.rejected();
}); });
it('Manage Packages Dialog: Sort Versions Test', async function () { it('Manage Packages Dialog: Sort Versions Test', async function () {

View File

@@ -153,6 +153,7 @@ describe('Manage Package Providers', () => {
should.equal(await provider.canUseProvider(), true); should.equal(await provider.canUseProvider(), true);
}); });
/* Tests disabled. Tracking issue: https://github.com/microsoft/azuredatastudio/issues/8877
it('Pip getPackageOverview should return package info successfully', async function (): Promise<void> { it('Pip getPackageOverview should return package info successfully', async function (): Promise<void> {
let testContext = createContext(); let testContext = createContext();
testContext.piPyClient.fetchPypiPackage = (packageName) => { testContext.piPyClient.fetchPypiPackage = (packageName) => {
@@ -163,7 +164,7 @@ describe('Manage Package Providers', () => {
let client = createPipyClient(testContext); let client = createPipyClient(testContext);
let provider = new LocalPipPackageManageProvider(serverInstallation.object, client.object); let provider = new LocalPipPackageManageProvider(serverInstallation.object, client.object);
should(provider.getPackageOverview('name')).resolvedWith({ await should(provider.getPackageOverview('name')).resolvedWith({
name: 'name', name: 'name',
versions: ['0.0.1', '0.0.2'], versions: ['0.0.1', '0.0.2'],
summary: 'summary' summary: 'summary'
@@ -180,12 +181,13 @@ describe('Manage Package Providers', () => {
let provider = new LocalCondaPackageManageProvider(serverInstallation.object); let provider = new LocalCondaPackageManageProvider(serverInstallation.object);
should(provider.getPackageOverview('name')).resolvedWith({ await should(provider.getPackageOverview('name')).resolvedWith({
name: 'name', name: 'name',
versions: ['0.0.1', '0.0.2'], versions: ['0.0.1', '0.0.2'],
summary: undefined summary: undefined
}); });
}); });
*/
function createContext(): TestContext { function createContext(): TestContext {
return { return {

View File

@@ -56,7 +56,7 @@ describe('Manage Packages', () => {
defaultLocation: 'invalid location' defaultLocation: 'invalid location'
}; };
let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options); let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options);
should(model.init()).rejectedWith(`Invalid default location '${options.defaultLocation}`); await should(model.init()).rejectedWith(`Invalid default location '${options.defaultLocation}`);
}); });
it('Init should throw exception given invalid default provider', async function (): Promise<void> { it('Init should throw exception given invalid default provider', async function (): Promise<void> {
@@ -70,9 +70,10 @@ describe('Manage Packages', () => {
defaultProviderId: 'invalid provider' defaultProviderId: 'invalid provider'
}; };
let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options); let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options);
should(model.init()).rejectedWith(`Invalid default provider id '${options.defaultProviderId}`); await should(model.init()).rejectedWith(`Invalid default provider id '${options.defaultProviderId}`);
}); });
/* Test disabled. Tracking issue: https://github.com/microsoft/azuredatastudio/issues/8877
it('Init should throw exception not given valid default location for single location mode', async function (): Promise<void> { it('Init should throw exception not given valid default location for single location mode', async function (): Promise<void> {
let testContext = createContext(); let testContext = createContext();
let provider = createProvider(testContext); let provider = createProvider(testContext);
@@ -83,8 +84,9 @@ describe('Manage Packages', () => {
multiLocations: false multiLocations: false
}; };
let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options); let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, options);
should(model.init()).rejectedWith(`Default location not specified for single location mode`); await should(model.init()).rejectedWith(`Default location not specified for single location mode`);
}); });
*/
it('Init should set default options given undefined', async function (): Promise<void> { it('Init should set default options given undefined', async function (): Promise<void> {
@@ -268,11 +270,12 @@ describe('Manage Packages', () => {
let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, undefined); let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, undefined);
should.equal(model.currentPackageManageProvider, undefined); should.equal(model.currentPackageManageProvider, undefined);
should(model.listPackages()).rejected(); await should(model.listPackages()).rejected();
should(model.installPackages(TypeMoq.It.isAny())).rejected(); await should(model.installPackages(TypeMoq.It.isAny())).rejected();
should(model.uninstallPackages(TypeMoq.It.isAny())).rejected(); await should(model.uninstallPackages(TypeMoq.It.isAny())).rejected();
}); });
/* Test disabled. Tracking issue: https://github.com/microsoft/azuredatastudio/issues/8877
it('current provider should install and uninstall packages successfully', async function (): Promise<void> { it('current provider should install and uninstall packages successfully', async function (): Promise<void> {
let testContext1 = createContext(); let testContext1 = createContext();
testContext1.provider.providerId = 'providerId1'; testContext1.provider.providerId = 'providerId1';
@@ -310,12 +313,14 @@ describe('Manage Packages', () => {
await model.init(); await model.init();
model.changeProvider('providerId2'); model.changeProvider('providerId2');
should(model.listPackages()).resolvedWith(packages);
should(model.installPackages(packages)).resolved(); await should(model.listPackages()).resolvedWith(packages);
should(model.uninstallPackages(packages)).resolved(); await should(model.installPackages(packages)).resolved();
should(model.getPackageOverview('p1')).resolved(); await should(model.uninstallPackages(packages)).resolved();
should(model.getLocationTitle()).rejectedWith('location title 2'); await should(model.getPackageOverview('p1')).resolved();
await should(model.getLocationTitle()).rejectedWith('location title 2');
}); });
*/
function createContext(): TestContext { function createContext(): TestContext {
return { return {