Skip to content

Commit a0bc835

Browse files
authored
test: adds basic coverage for --preset flag and CHANGELOG output (conventional-changelog#723)
closes conventional-changelog#720
1 parent a61d8cf commit a0bc835

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/preset.spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* global describe it beforeEach, afterEach */
2+
3+
const shell = require('shelljs')
4+
const fs = require('fs')
5+
6+
require('chai').should()
7+
8+
function exec (opt) {
9+
const cli = require('../command')
10+
opt = cli.parse(`standard-version ${opt} --silent`)
11+
opt.skip = { commit: true, tag: true }
12+
return require('../index')(opt)
13+
}
14+
15+
describe('presets', () => {
16+
beforeEach(function () {
17+
shell.rm('-rf', 'tmp')
18+
shell.config.silent = true
19+
shell.mkdir('tmp')
20+
shell.cd('tmp')
21+
shell.exec('git init')
22+
shell.exec('git config commit.gpgSign false')
23+
shell.exec('git config core.autocrlf false')
24+
shell.exec('git commit --allow-empty -m "initial commit"')
25+
shell.exec('git commit --allow-empty -m "feat: A feature commit."')
26+
shell.exec('git commit --allow-empty -m "perf: A performance change."')
27+
shell.exec('git commit --allow-empty -m "chore: A chore commit."')
28+
shell.exec('git commit --allow-empty -m "ci: A ci commit."')
29+
shell.exec('git commit --allow-empty -m "custom: A custom commit."')
30+
})
31+
32+
afterEach(function () {
33+
shell.cd('../')
34+
shell.rm('-rf', 'tmp')
35+
})
36+
37+
it('Conventional Commits (default)', async function () {
38+
await exec()
39+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
40+
content.should.contain('### Features')
41+
content.should.not.contain('### Performance Improvements')
42+
content.should.not.contain('### Custom')
43+
})
44+
45+
it('Angular', async function () {
46+
await exec('--preset angular')
47+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
48+
content.should.contain('### Features')
49+
content.should.contain('### Performance Improvements')
50+
content.should.not.contain('### Custom')
51+
})
52+
})

0 commit comments

Comments
 (0)