From 053a24cead99a945c540c19638ca3a16045215c9 Mon Sep 17 00:00:00 2001 From: Joe Bottigliero Date: Mon, 17 Jun 2019 15:45:47 -0500 Subject: [PATCH] test: adds tests for .versionrc.json usage (#381) --- test.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test.js b/test.js index 02b3279ba..4b1371ff7 100644 --- a/test.js +++ b/test.js @@ -409,6 +409,21 @@ describe('cli', function () { }) describe('precommit hook', function () { + it('should run the precommit hook when provided via .versionrc.json (#371)', function () { + fs.writeFileSync('.versionrc.json', JSON.stringify({ + 'scripts': { + 'precommit': 'node scripts/precommit' + } + }), 'utf-8') + + writeHook('precommit') + fs.writeFileSync('CHANGELOG.md', 'legacy header format\n', 'utf-8') + commit('feat: first commit') + let result = execCli() + result.code.should.equal(0) + result.stderr.should.match(/precommit ran/) + }) + it('should run the precommit hook when provided', function () { writePackageJson('1.0.0', { 'standard-version': { @@ -1071,6 +1086,19 @@ describe('standard-version', function () { content.should.include('http://www.foo.com/1') }) + it('reads config from .versionrc.json', function () { + // write configuration that overrides default issue + // URL format. + fs.writeFileSync('.versionrc.json', JSON.stringify({ + issueUrlFormat: 'http://www.foo.com/{{id}}' + }), 'utf-8') + commit('feat: another commit addresses issue #1') + execCli() + // CHANGELOG should have the new issue URL format. + const content = fs.readFileSync('CHANGELOG.md', 'utf-8') + content.should.include('http://www.foo.com/1') + }) + it('.versionrc : releaseCommitMessageFormat', function () { // write configuration that overrides default issue // URL format.