Fixed an issue with setting the default location in package management (#10263)

This commit is contained in:
Leila Lali
2020-05-04 17:00:51 -07:00
committed by GitHub
parent 5498c1c3a9
commit a7c4a259ad
2 changed files with 31 additions and 1 deletions

View File

@@ -133,7 +133,7 @@ export class ManagePackagesDialogModel {
* Returns the default location
*/
public get defaultLocation(): string | undefined {
return this.options.defaultLocation || this.targetLocationTypes.length > 0 ? this.targetLocationTypes[0] : undefined;
return this.options.defaultLocation || (this.targetLocationTypes.length > 0 ? this.targetLocationTypes[0] : undefined);
}
/**

View File

@@ -199,6 +199,36 @@ describe('Manage Packages', () => {
should.deepEqual(model.getPackageTypes('location1'), [{providerId: 'providerId1', packageType: 'package-type1'}]);
});
it('Should set default location to one set in given options', async function (): Promise<void> {
let testContext1 = createContext();
testContext1.provider.providerId = 'providerId1';
testContext1.provider.packageTarget = {
location: 'location1',
packageType: 'package-type1'
};
let testContext2 = createContext();
testContext2.provider.providerId = 'providerId2';
testContext2.provider.packageTarget = {
location: 'location1',
packageType: 'package-type2'
};
testContext2.provider.canUseProvider = () => { return Promise.resolve(false); };
let providers = new Map<string, IPackageManageProvider>();
providers.set(testContext1.provider.providerId, createProvider(testContext1));
providers.set(testContext2.provider.providerId, createProvider(testContext2));
let model = new ManagePackagesDialogModel(jupyterServerInstallation, providers, {
defaultLocation: testContext2.provider.packageTarget.location,
defaultProviderId: testContext2.provider.providerId
});
await model.init();
should.equal(model.defaultLocation, testContext2.provider.packageTarget.location);
should.deepEqual(model.getPackageTypes('location1'), [{providerId: 'providerId1', packageType: 'package-type1'}]);
});
it('changeProvider should change current provider successfully', async function (): Promise<void> {
let testContext1 = createContext();
testContext1.provider.providerId = 'providerId1';