Skip to content

Commit

Permalink
feat(prompt-cli): add test conventional-changelog#51
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Nov 8, 2018
1 parent 5eb8bcf commit 72fb3e4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
25 changes: 25 additions & 0 deletions @commitlint/prompt-cli/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import path from 'path';
import {git} from '@commitlint/test';
import test from 'ava';
import execa from 'execa';
import stream from 'string-to-stream';

const bin = path.join(__dirname, './cli.js');

const cli = (args, options) => {
return (input = '') => {
const c = execa(bin, args, {
capture: ['stdout'],
cwd: options.cwd,
env: options.env
});
stream(input).pipe(c.stdin);
return c.catch(err => err);
};
};

test('should print warning if stage is empty', async t => {
const cwd = await git.bootstrap();
const actual = await cli([], {cwd})('foo: bar');
t.true(actual.stdout.includes('Nothing to commit.'));
});
8 changes: 6 additions & 2 deletions @commitlint/prompt-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"commit": "$npm_package_bin_commit",
"deps": "dep-check",
"pkg": "pkg-check --skip-main",
"lint": "xo"
"lint": "xo",
"test": "ava -c 4 --verbose"
},
"xo": false,
"repository": {
Expand All @@ -36,7 +37,10 @@
},
"dependencies": {
"@commitlint/prompt": "^7.2.0",
"@commitlint/test": "^7.1.2",
"ava": "^0.25.0",
"execa": "0.9.0",
"meow": "3.7.0"
"meow": "3.7.0",
"string-to-stream": "^1.1.1"
}
}

0 comments on commit 72fb3e4

Please sign in to comment.