-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): adds test suite, fixed several Node 0.10 issues along th…
…e way
- Loading branch information
Showing
6 changed files
with
151 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* global describe it beforeEach afterEach */ | ||
|
||
'use strict' | ||
|
||
var shell = require('shelljs') | ||
var fs = require('fs') | ||
var path = require('path') | ||
var cliPath = path.resolve(__dirname, './index.js') | ||
|
||
require('chai').should() | ||
|
||
function commit (msg) { | ||
shell.exec('git commit --allow-empty -m"' + msg + '"') | ||
} | ||
|
||
describe('cli', function () { | ||
beforeEach(function () { | ||
shell.rm('-rf', 'tmp') | ||
shell.config.silent = true | ||
shell.mkdir('tmp') | ||
shell.cd('tmp') | ||
shell.exec('git init') | ||
commit('root-commit') | ||
}) | ||
|
||
afterEach(function () { | ||
shell.cd('../') | ||
shell.rm('-rf', 'tmp') | ||
}) | ||
|
||
describe('CHANGELOG.md does not exist', function () { | ||
it('populates changelog with commits since last tag by default', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
|
||
commit('feat: first commit') | ||
shell.exec('git tag -a v1.0.0 -m "my awesome first release"') | ||
commit('fix: patch release') | ||
|
||
shell.exec(cliPath).code.should.equal(0) | ||
|
||
var content = fs.readFileSync('CHANGELOG.md', 'utf-8') | ||
content.should.match(/patch release/) | ||
content.should.not.match(/first commit/) | ||
}) | ||
|
||
it('includes all commits if --first-release is true', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.1' | ||
}), 'utf-8') | ||
|
||
commit('feat: first commit') | ||
commit('fix: patch release') | ||
shell.exec(cliPath + ' --first-release').code.should.equal(0) | ||
|
||
var content = fs.readFileSync('CHANGELOG.md', 'utf-8') | ||
content.should.match(/patch release/) | ||
content.should.match(/first commit/) | ||
shell.exec('git tag').output.should.match(/1\.0\.1/) | ||
}) | ||
}) | ||
|
||
describe('CHANGELOG.md exists', function () { | ||
it('appends the new release above the last release, removing the old header', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
|
||
commit('feat: first commit') | ||
shell.exec('git tag -a v1.0.0 -m "my awesome first release"') | ||
commit('fix: patch release') | ||
|
||
shell.exec(cliPath).code.should.equal(0) | ||
var content = fs.readFileSync('CHANGELOG.md', 'utf-8') | ||
content.should.match(/1\.0\.1/) | ||
content.should.not.match(/legacy header format/) | ||
}) | ||
}) | ||
}) |