Skip to content

Commit 72fb3e4

Browse files
committed
feat(prompt-cli): add test conventional-changelog#51
1 parent 5eb8bcf commit 72fb3e4

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

@commitlint/prompt-cli/cli.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import path from 'path';
2+
import {git} from '@commitlint/test';
3+
import test from 'ava';
4+
import execa from 'execa';
5+
import stream from 'string-to-stream';
6+
7+
const bin = path.join(__dirname, './cli.js');
8+
9+
const cli = (args, options) => {
10+
return (input = '') => {
11+
const c = execa(bin, args, {
12+
capture: ['stdout'],
13+
cwd: options.cwd,
14+
env: options.env
15+
});
16+
stream(input).pipe(c.stdin);
17+
return c.catch(err => err);
18+
};
19+
};
20+
21+
test('should print warning if stage is empty', async t => {
22+
const cwd = await git.bootstrap();
23+
const actual = await cli([], {cwd})('foo: bar');
24+
t.true(actual.stdout.includes('Nothing to commit.'));
25+
});

@commitlint/prompt-cli/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"commit": "$npm_package_bin_commit",
1414
"deps": "dep-check",
1515
"pkg": "pkg-check --skip-main",
16-
"lint": "xo"
16+
"lint": "xo",
17+
"test": "ava -c 4 --verbose"
1718
},
1819
"xo": false,
1920
"repository": {
@@ -36,7 +37,10 @@
3637
},
3738
"dependencies": {
3839
"@commitlint/prompt": "^7.2.0",
40+
"@commitlint/test": "^7.1.2",
41+
"ava": "^0.25.0",
3942
"execa": "0.9.0",
40-
"meow": "3.7.0"
43+
"meow": "3.7.0",
44+
"string-to-stream": "^1.1.1"
4145
}
4246
}

0 commit comments

Comments
 (0)