mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
Fix missing dev dependencies (#35)
* Add test for missing devDependencies case * Add check for depType
This commit is contained in:
parent
6842afddac
commit
74c3aba2ba
3 changed files with 40 additions and 3 deletions
|
@ -23,7 +23,7 @@ function extractDependencies(packageJson) {
|
|||
const depTypes = ['dependencies', 'devDependencies'];
|
||||
return depTypes.reduce((allDeps, depType) => {
|
||||
// loop through each dependency within a type
|
||||
const depNames = Object.keys(packageJson[depType]) || [];
|
||||
const depNames = packageJson[depType] ? Object.keys(packageJson[depType]) : [];
|
||||
return allDeps.concat(depNames.map(depName => ({
|
||||
depType,
|
||||
depName,
|
||||
|
|
30
test/_fixtures/package.json/inputs/02.json
Normal file
30
test/_fixtures/package.json/inputs/02.json
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "renovate",
|
||||
"description": "Client node modules for renovate",
|
||||
"version": "1.0.0",
|
||||
"author": "Rhys Arkins <rhys@keylocation.sg>",
|
||||
"bugs": "https://github.com/singapore/renovate/issues",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Rhys Arkins"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"autoprefixer": "6.5.0",
|
||||
"bower": "~1.6.0",
|
||||
"browserify": "13.1.0",
|
||||
"browserify-css": "0.9.2",
|
||||
"cheerio": "0.22.0",
|
||||
"config": "1.21.0"
|
||||
},
|
||||
"homepage": "https://keylocation.sg",
|
||||
"keywords": [
|
||||
"Key Location",
|
||||
"Singapore"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/singapore/renovate.git"
|
||||
}
|
||||
}
|
|
@ -7,19 +7,26 @@ chai.should();
|
|||
|
||||
npm.setLogger(winston);
|
||||
|
||||
const inputContent = fs.readFileSync('./test/_fixtures/package.json/inputs/01.json', 'utf8');
|
||||
const input01Content = fs.readFileSync('./test/_fixtures/package.json/inputs/01.json', 'utf8');
|
||||
const input02Content = fs.readFileSync('./test/_fixtures/package.json/inputs/02.json', 'utf8');
|
||||
|
||||
describe('npm helper', () => {
|
||||
describe('extractDependencies', () => {
|
||||
const extractedDependencies = npm.extractDependencies(JSON.parse(inputContent));
|
||||
it('returns an array of correct length', () => {
|
||||
const extractedDependencies = npm.extractDependencies(JSON.parse(input01Content));
|
||||
extractedDependencies.should.be.instanceof(Array);
|
||||
extractedDependencies.should.have.length(10);
|
||||
});
|
||||
it('each element contains non-null depType, depName, currentVersion', () => {
|
||||
const extractedDependencies = npm.extractDependencies(JSON.parse(input01Content));
|
||||
extractedDependencies.every(dep => dep.depType && dep.depName && dep.currentVersion)
|
||||
.should.eql(true);
|
||||
});
|
||||
it('supports null devDependencies', () => {
|
||||
const extractedDependencies = npm.extractDependencies(JSON.parse(input02Content));
|
||||
extractedDependencies.should.be.instanceof(Array);
|
||||
extractedDependencies.should.have.length(6);
|
||||
});
|
||||
});
|
||||
describe('getUpgrades', () => {
|
||||
const testVersions = ['0.1.0', '1.0.0', '1.0.1', '1.1.0', '2.0.0-alpha1', '2.0.0', '2.0.1', '3.0.0', '3.1.0'];
|
||||
|
|
Loading…
Reference in a new issue