Skip to content
Snippets Groups Projects
Commit 1e240179 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

Add tests for package-json

commit 8e72ab18f39f6e177757e1442e9f491d22982e58
Author: Rhys Arkins <rhys@keylocation.sg>
Date:   Thu Jan 12 09:33:33 2017 +0100

    Remove use strict

commit 3d13fa9e69b0050ba211128b8b73d210eb0b549a
Author: Rhys Arkins <rhys@keylocation.sg>
Date:   Thu Jan 12 09:31:22 2017 +0100

    Add circle.yml

commit d5fad78f3847f8b384a508d3ab6e4cd19939be4e
Author: Rhys Arkins <rhys@keylocation.sg>
Date:   Thu Jan 12 09:28:58 2017 +0100

    Try use strict

commit 32ed86bfb6e04fe4270381dc3faa1184192a6f91
Author: Rhys Arkins <rhys@keylocation.sg>
Date:   Thu Jan 12 09:12:46 2017 +0100

    Add package-json tests
parent 4291c076
No related branches found
No related tags found
No related merge requests found
File moved
const changelog = require('changelog'); const changelog = require('changelog');
const github = require('./helpers/github'); const github = require('./helpers/github');
const npm = require('./helpers/npm'); const npm = require('./helpers/npm');
const packageJson = require('./helpers/packageJson'); const packageJson = require('./helpers/package-json');
let config = null; let config = null;
let logger = null; let logger = null;
......
machine:
node:
version: 6
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"start": "node app", "start": "node app",
"test": "eslint ." "test": "mocha --recursive --reporter spec"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -36,9 +36,11 @@ ...@@ -36,9 +36,11 @@
"winston": "2.3.0" "winston": "2.3.0"
}, },
"devDependencies": { "devDependencies": {
"chai": "3.5.0",
"eslint": "3.13.1", "eslint": "3.13.1",
"eslint-config-airbnb-base": "11.0.1", "eslint-config-airbnb-base": "11.0.1",
"eslint-plugin-import": "2.2.0", "eslint-plugin-import": "2.2.0",
"eslint-plugin-promise": "3.4.0" "eslint-plugin-promise": "3.4.0",
"mocha": "3.2.0"
} }
} }
{
"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"
},
"devDependencies": {
"angular": "^1.5.8",
"angular-touch": "1.5.8",
"angular-sanitize": "1.5.8",
"@angular/core": "4.0.0-beta.1"
},
"homepage": "https://keylocation.sg",
"keywords": [
"Key Location",
"Singapore"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/singapore/renovate.git"
}
}
{
"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.1",
"config": "1.21.0"
},
"devDependencies": {
"angular": "^1.5.8",
"angular-touch": "1.5.8",
"angular-sanitize": "1.5.8",
"@angular/core": "4.0.0-beta.1"
},
"homepage": "https://keylocation.sg",
"keywords": [
"Key Location",
"Singapore"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/singapore/renovate.git"
}
}
{
"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"
},
"devDependencies": {
"angular": "^1.5.8",
"angular-touch": "1.6.1",
"angular-sanitize": "1.5.8",
"@angular/core": "4.0.0-beta.1"
},
"homepage": "https://keylocation.sg",
"keywords": [
"Key Location",
"Singapore"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/singapore/renovate.git"
}
}
{
"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"
},
"devDependencies": {
"angular": "^1.5.8",
"angular-touch": "1.5.8",
"angular-sanitize": "1.6.1",
"@angular/core": "4.0.0-beta.1"
},
"homepage": "https://keylocation.sg",
"keywords": [
"Key Location",
"Singapore"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/singapore/renovate.git"
}
}
const expect = require('chai').expect;
const fs = require('fs');
const packageJson = require('../../app/helpers/package-json');
const winston = require('winston');
packageJson.setLogger(winston);
const inputContent = fs.readFileSync('./test/_fixtures/package.json/inputs/01.json', 'utf8');
describe('package.json helper', function() {
describe('setNewValue', function() {
it('replaces a dependency value', function() {
const outputContent = fs.readFileSync('./test/_fixtures/package.json/outputs/011.json', 'utf8');
const testContent =
packageJson.setNewValue(inputContent, 'dependencies', 'cheerio', '0.22.1');
expect(testContent).to.equal(outputContent);
});
it('replaces only the first instance of a value', function() {
const outputContent = fs.readFileSync('./test/_fixtures/package.json/outputs/012.json', 'utf8');
const testContent =
packageJson.setNewValue(inputContent, 'devDependencies', 'angular-touch', '1.6.1');
expect(testContent).to.equal(outputContent);
});
it('replaces only the second instance of a value', function() {
const outputContent = fs.readFileSync('./test/_fixtures/package.json/outputs/013.json', 'utf8');
const testContent =
packageJson.setNewValue(inputContent, 'devDependencies', 'angular-sanitize', '1.6.1');
expect(testContent).to.equal(outputContent);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment