Skip to content

Commit 71cdfb7

Browse files
mansonakategengler
authored andcommitted
adding test to check the use of npm prune
1 parent f2b8f43 commit 71cdfb7

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

test/dependency-manager-adapters/npm-adapter-test.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('npmAdapter', () => {
4343

4444
describe('#_install', () => {
4545
describe('without yarn', () => {
46-
it('runs npm prune and npm install', () => {
46+
it('only runs npm install with npm 5', () => {
4747
writeJSONFile('package.json', fixturePackage);
4848
let runCount = 0;
4949
let stubbedRun = generateMockRun([{
@@ -53,20 +53,52 @@ describe('npmAdapter', () => {
5353
expect(opts).to.have.property('cwd', tmpdir);
5454
return RSVP.resolve();
5555
},
56-
}, {
56+
},{
57+
command: 'npm --version',
58+
callback() {
59+
runCount++;
60+
return RSVP.resolve({stdout: '5.7.1'});
61+
},
62+
}], { allowPassthrough: false });
63+
64+
return new NpmAdapter({
65+
cwd: tmpdir,
66+
run: stubbedRun,
67+
})._install().then(() => {
68+
expect(runCount).to.equal(2);
69+
});
70+
});
71+
72+
it('runs npm prune and npm install with npm 4', () => {
73+
writeJSONFile('package.json', fixturePackage);
74+
let runCount = 0;
75+
let stubbedRun = generateMockRun([{
76+
command: 'npm install --no-shrinkwrap',
77+
callback(command, args, opts) {
78+
runCount++;
79+
expect(opts).to.have.property('cwd', tmpdir);
80+
return RSVP.resolve();
81+
},
82+
},{
5783
command: 'npm prune',
5884
callback(command, args, opts) {
5985
runCount++;
6086
expect(opts).to.have.property('cwd', tmpdir);
6187
return RSVP.resolve();
6288
},
89+
}, {
90+
command: 'npm --version',
91+
callback() {
92+
runCount++;
93+
return RSVP.resolve({stdout: '4.7.1'});
94+
},
6395
}], { allowPassthrough: false });
6496

6597
return new NpmAdapter({
6698
cwd: tmpdir,
6799
run: stubbedRun,
68100
})._install().then(() => {
69-
expect(runCount).to.equal(2, 'Both commands should run');
101+
expect(runCount).to.equal(3, 'All three commands should run');
70102
});
71103
});
72104

@@ -80,10 +112,10 @@ describe('npmAdapter', () => {
80112
return RSVP.resolve();
81113
},
82114
}, {
83-
command: 'npm prune',
115+
command: 'npm --version',
84116
callback() {
85117
runCount++;
86-
return RSVP.resolve();
118+
return RSVP.resolve({stdout: '5.7.1'});
87119
},
88120
}], { allowPassthrough: false });
89121

@@ -92,7 +124,7 @@ describe('npmAdapter', () => {
92124
run: stubbedRun,
93125
managerOptions: ['--no-optional'],
94126
})._install().then(() => {
95-
expect(runCount).to.equal(2, 'Both commands should run');
127+
expect(runCount).to.equal(2);
96128
});
97129
});
98130
});

0 commit comments

Comments
 (0)