Skip to content

Commit

Permalink
adding test to check the use of npm prune
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona authored and kategengler committed May 15, 2019
1 parent f2b8f43 commit 71cdfb7
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions test/dependency-manager-adapters/npm-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('npmAdapter', () => {

describe('#_install', () => {
describe('without yarn', () => {
it('runs npm prune and npm install', () => {
it('only runs npm install with npm 5', () => {
writeJSONFile('package.json', fixturePackage);
let runCount = 0;
let stubbedRun = generateMockRun([{
Expand All @@ -53,20 +53,52 @@ describe('npmAdapter', () => {
expect(opts).to.have.property('cwd', tmpdir);
return RSVP.resolve();
},
}, {
},{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({stdout: '5.7.1'});
},
}], { allowPassthrough: false });

return new NpmAdapter({
cwd: tmpdir,
run: stubbedRun,
})._install().then(() => {
expect(runCount).to.equal(2);
});
});

it('runs npm prune and npm install with npm 4', () => {
writeJSONFile('package.json', fixturePackage);
let runCount = 0;
let stubbedRun = generateMockRun([{
command: 'npm install --no-shrinkwrap',
callback(command, args, opts) {
runCount++;
expect(opts).to.have.property('cwd', tmpdir);
return RSVP.resolve();
},
},{
command: 'npm prune',
callback(command, args, opts) {
runCount++;
expect(opts).to.have.property('cwd', tmpdir);
return RSVP.resolve();
},
}, {
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({stdout: '4.7.1'});
},
}], { allowPassthrough: false });

return new NpmAdapter({
cwd: tmpdir,
run: stubbedRun,
})._install().then(() => {
expect(runCount).to.equal(2, 'Both commands should run');
expect(runCount).to.equal(3, 'All three commands should run');
});
});

Expand All @@ -80,10 +112,10 @@ describe('npmAdapter', () => {
return RSVP.resolve();
},
}, {
command: 'npm prune',
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve();
return RSVP.resolve({stdout: '5.7.1'});
},
}], { allowPassthrough: false });

Expand All @@ -92,7 +124,7 @@ describe('npmAdapter', () => {
run: stubbedRun,
managerOptions: ['--no-optional'],
})._install().then(() => {
expect(runCount).to.equal(2, 'Both commands should run');
expect(runCount).to.equal(2);
});
});
});
Expand Down

0 comments on commit 71cdfb7

Please sign in to comment.