Skip to content
Prev Previous commit
Next Next commit
Revert "test: drop unnecessary notThrowsAsync"
This reverts commit eba4002.
  • Loading branch information
armano2 committed Jan 3, 2020
commit fb89e2d1bf8d397bef7d0215f6466d6e3cf2ebc5
125 changes: 71 additions & 54 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,70 +136,85 @@ test('should produce no error output with -q flag', async t => {
});

test('should work with husky commitmsg hook and git commit', async t => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky commitmsg hook in sub packages', async t => {
const upper = await git.bootstrap('fixtures/husky');
const cwd = path.join(upper, 'integration');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd: upper});
await t.notThrowsAsync(async () => {
const upper = await git.bootstrap('fixtures/husky');
const cwd = path.join(upper, 'integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e`}}},
{cwd: upper}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e $GIT_PARAMS', async t => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
{cwd}
);
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e %GIT_PARAMS%', async t => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
{cwd}
);
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async t => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
{cwd}
);
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async t => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
{cwd}
);
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should allow reading of environment variables for edit file, succeeding if valid', async t => {
Expand Down Expand Up @@ -276,17 +291,19 @@ test('should pick up config from inside git repo with precedence and fail accord
});

test('should handle --amend with signoff', async t => {
const cwd = await git.bootstrap('fixtures/signoff');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa(
'git',
['commit', '-m', '"test: this should work"', '--signoff'],
{cwd}
);
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/signoff');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa(
'git',
['commit', '-m', '"test: this should work"', '--signoff'],
{cwd}
);
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
});
});

test('should handle linting with issue prefixes', async t => {
Expand Down