From 17b09269fa5603e0be7f5ffe5ce67996f7cf4176 Mon Sep 17 00:00:00 2001 From: Michael Moussa Date: Wed, 10 Oct 2018 14:23:54 -0400 Subject: [PATCH] Add tests for `.auto-changelog` feature * `.auto-changelog` is ignored if `package.json` defines `auto-changelog` settings * `.auto-changelog` gets used if present * CLI params override `.auto-changelog` --- test/run.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/run.js b/test/run.js index 1baa7362..0aa3bb85 100644 --- a/test/run.js +++ b/test/run.js @@ -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')