Skip to content

Commit

Permalink
Add tests for .auto-changelog feature
Browse files Browse the repository at this point in the history
* `.auto-changelog` is ignored if `package.json` defines `auto-changelog` settings
* `.auto-changelog` gets used if present
* CLI params override `.auto-changelog`
  • Loading branch information
michaelmoussa authored and cookpete committed Nov 8, 2018
1 parent 9d80b9d commit 17b0926
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ describe('run', () => {
return run(['', '', '--output', 'should-be-this.md'])
})

it('uses options from .auto-changelog', async () => {
const expected = await readFile(join(__dirname, 'data', 'template-keepachangelog.md'))
mock('fileExists', path => path === '.auto-changelog')
mock('readJson', path => {
return path === '.auto-changelog' ? { template: 'keepachangelog' } : null
})
mock('writeFile', (output, log) => {
expect(log).to.equal(expected)
})

return run(['', ''])
})

it('command line options override options from .auto-changelog', async () => {
mock('fileExists', () => true)
mock('readJson', (path) => {
return path === '.auto-changelog' ? { output: 'should-not-be-this.md' } : null
})
mock('writeFile', (output, log) => {
expect(output).to.equal('should-be-this.md')
})

return run(['', '', '--output', 'should-be-this.md'])
})

it('supports unreleased option', () => {
mock('writeFile', (output, log) => {
expect(log).to.include('Unreleased')
Expand Down

0 comments on commit 17b0926

Please sign in to comment.