Skip to content

Commit

Permalink
FIxing installation tests.
Browse files Browse the repository at this point in the history
At last, ALL tests are passing, with slight undefined vs null modifications! 🥳
That could be reclaimed later on if it really matters.
  • Loading branch information
Polgár Márton committed Sep 29, 2023
1 parent 6e6380a commit de392dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
26 changes: 13 additions & 13 deletions spec2/install-spec.js → spec/install-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('apm install', () => {
expect(fs.existsSync(existingTestModuleFile)).toBeFalsy();
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand All @@ -121,7 +121,7 @@ describe('apm install', () => {

runs(() => {
expect(JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'))).version).toBe('1.1.0');
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand All @@ -136,7 +136,7 @@ describe('apm install', () => {

runs(() => {
expect(JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'))).version).toBe('1.1.0');
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -173,7 +173,7 @@ describe('apm install', () => {
expect(fs.existsSync(testModuleDirectory)).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});
});
Expand All @@ -195,7 +195,7 @@ describe('apm install', () => {
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'index2.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -305,7 +305,7 @@ describe('apm install', () => {
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'index2.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -424,18 +424,17 @@ describe('apm install', () => {
beforeEach(() => {
install = new Install();

const fakeCloneRepository = (url, ...args) => {
const callback = args[args.length - 1];
const fakeCloneRepository = async (url, ..._rest) => {
if (url !== urls[2]) {
callback(new Error('Failed to clone'));
throw new Error('Failed to clone');
}
};

spyOn(install, 'cloneNormalizedUrl').andCallFake(fakeCloneRepository);
});

it('tries cloning the next URL until one works', () => {
install.cloneFirstValidGitUrl(urls, {}, () => {});
it('tries cloning the next URL until one works', async () => {
await install.cloneFirstValidGitUrl(urls, {}, () => {});
expect(install.cloneNormalizedUrl.calls.length).toBe(3);
expect(install.cloneNormalizedUrl.argsForCall[0][0]).toBe(urls[0]);
expect(install.cloneNormalizedUrl.argsForCall[1][0]).toBe(urls[1]);
Expand Down Expand Up @@ -565,7 +564,7 @@ describe('apm install', () => {
});
});

describe('when installing a registred package and --json is specified', () => {
describe('when installing a registered package and --json is specified', () => {
beforeEach(() => {
const callback = jasmine.createSpy('callback');
apm.run(['install', 'test-module', 'test-module2', '--json'], callback);
Expand Down Expand Up @@ -609,7 +608,7 @@ describe('apm install', () => {

waitsFor('waiting for install to complete', 600000, () => callback.callCount === 1);
runs(() => {
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();

const testModuleDirectory = path.join(atomHome, 'packages', 'native-package');
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
Expand All @@ -624,5 +623,6 @@ describe('apm install', () => {
});
});
});

});
});
9 changes: 3 additions & 6 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,7 @@ Run ppm -v after installing Git to see what version has been detected.\
const gitPackageInfo = this.getHostedGitInfo(name);

if (gitPackageInfo || (name.indexOf('file://') === 0)) {
await this.installGitPackage(name, options, options.argv.branch || options.argv.tag);
return;
return await this.installGitPackage(name, options, options.argv.branch || options.argv.tag);
}
if (name === '.') {
await this.installDependencies(options);
Expand All @@ -701,7 +700,7 @@ with Pulsar will be used.\
`.yellow
);
}
await this.installRegisteredPackage({name, version}, options);
return await this.installRegisteredPackage({name, version}, options);
};

if (packagesFilePath) {
Expand All @@ -724,9 +723,7 @@ with Pulsar will be used.\
await this.loadInstalledAtomMetadata();
});
packageNames.forEach(packageName =>
void commands.push(async () => {
await installPackage(packageName);
})
void commands.push(async () => await installPackage(packageName))
);
const iteratee = async fn => await fn();
try {
Expand Down

0 comments on commit de392dd

Please sign in to comment.