Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Coe committed Jun 5, 2017
1 parent b1f42a4 commit 10f3e03
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
6 changes: 5 additions & 1 deletion lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ const runLifecycleScript = require('../run-lifecycle-script')
const semver = require('semver')
const writeFile = require('../write-file')

const configsToUpdate = {}
var configsToUpdate = {}

function Bump (args, pkg) {
// reset the cache of updated config files each
// time we perform the version bump step.
configsToUpdate = {}

if (args.skip.bump) return Promise.resolve()
var newVersion = pkg.version
return runLifecycleScript(args, 'prebump', null)
Expand Down
52 changes: 24 additions & 28 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,38 +690,34 @@ describe('standard-version', function () {
})

describe('skip', () => {
describe('skip bump and changelog generation phase', function () {
it('do not bump the version', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')
it('allows bump and changelog generation to be skipped', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')

commit('feat: first commit')
return execCliAsync('--skip.bump true --skip.changelog true')
.then(function () {
getPackageVersion().should.equal('1.0.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.equal(changelogContent)
})
})
commit('feat: first commit')
return execCliAsync('--skip.bump true --skip.changelog true')
.then(function () {
getPackageVersion().should.equal('1.0.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.equal(changelogContent)
})
})

describe('skip commit phase', function () {
it('do not bump the version', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')
it('allows the commit phase to be skipped', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')

commit('feat: new feature from branch')
return execCliAsync('--skip.commit true')
.then(function () {
getPackageVersion().should.equal('1.1.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)
// check last commit message
shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature from branch/)
})
})
commit('feat: new feature from branch')
return execCliAsync('--skip.commit true')
.then(function () {
getPackageVersion().should.equal('1.1.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)
// check last commit message
shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature from branch/)
})
})
})
})

0 comments on commit 10f3e03

Please sign in to comment.