Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adds basic coverage for --preset flag and CHANGELOG output #723

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions test/preset.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* global describe it beforeEach, afterEach */

const shell = require('shelljs')
const fs = require('fs')

require('chai').should()

function exec (opt) {
const cli = require('../command')
opt = cli.parse(`standard-version ${opt} --silent`)
opt.skip = { commit: true, tag: true }
return require('../index')(opt)
}

describe('presets', () => {
beforeEach(function () {
shell.rm('-rf', 'tmp')
shell.config.silent = true
shell.mkdir('tmp')
shell.cd('tmp')
shell.exec('git init')
shell.exec('git config commit.gpgSign false')
shell.exec('git config core.autocrlf false')
shell.exec('git commit --allow-empty -m "initial commit"')
shell.exec('git commit --allow-empty -m "feat: A feature commit."')
shell.exec('git commit --allow-empty -m "perf: A performance change."')
shell.exec('git commit --allow-empty -m "chore: A chore commit."')
shell.exec('git commit --allow-empty -m "ci: A ci commit."')
shell.exec('git commit --allow-empty -m "custom: A custom commit."')
})

afterEach(function () {
shell.cd('../')
shell.rm('-rf', 'tmp')
})

it('Conventional Commits (default)', async function () {
await exec()
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.contain('### Features')
content.should.not.contain('### Performance Improvements')
content.should.not.contain('### Custom')
})

it('Angular', async function () {
await exec('--preset angular')
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.contain('### Features')
content.should.contain('### Performance Improvements')
content.should.not.contain('### Custom')
})
})