This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
forked from streamich/git-cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request streamich#145 from theashraf/test/integration-test
test: 💍 add integration test
- Loading branch information
Showing
9 changed files
with
1,645 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ yarn-error.log | |
dist/ | ||
package-lock.json | ||
/binaries/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"arrowParens": "always", | ||
"bracketSpacing": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "mailonline/mocha" | ||
} | ||
"extends": "mailonline/jest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`git-cz --help 1`] = ` | ||
" | ||
Semantic emojified git commit, git-cz | ||
Usage: git-cz [options] | ||
options: | ||
-h, --help show usage information | ||
-v, --version print version info and exit | ||
--disable-emoji don't add emoji to commit title | ||
--non-interactive run git-cz in non-interactive mode | ||
non-interactive mode options: | ||
--type type of the commit, defaults to \\"chore\\" | ||
--subject message of the commit, defaults to \\"automated commit\\" | ||
--scope semantic commit scope | ||
--body extended description of the commit | ||
--breaking description of breaking changes, if any | ||
--issues GitHub issues this commit closed, e.g \\"#123\\" | ||
--lerna Lerna mono-repo packages this commit affects | ||
" | ||
`; | ||
|
||
exports[`git-cz --non-interactive 1`] = ` | ||
"Running in dry mode. | ||
Will execute command: | ||
git commit --message 'chore: 🤖 automated commit' | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const pkg = require('../package.json'); | ||
const {runCLI} = require('./testUtils'); | ||
|
||
test('git-cz --help', async () => { | ||
const {getResult} = runCLI(['--help']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
test('git-cz --version', async () => { | ||
const {getResult} = runCLI(['--version']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result.trim()).toBe(pkg.version); | ||
}); | ||
|
||
test('git-cz --non-interactive', async () => { | ||
const {getResult} = runCLI(['--non-interactive', '--dry-run']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const path = require('path'); | ||
const spawn = require('spawncommand'); | ||
|
||
exports.keys = { | ||
down: '\u001B\u005B\u0042', | ||
enter: '\r', | ||
up: '\u001B\u005B\u0041' | ||
}; | ||
|
||
exports.runCLI = (args = []) => { | ||
const CLI_PATH = path.join(__dirname, '/../lib/cli'); | ||
|
||
const {promise, stdin} = spawn('node', [ | ||
CLI_PATH, | ||
...args | ||
]); | ||
|
||
const getResult = async () => { | ||
const {stdout} = await promise; | ||
|
||
return stdout; | ||
}; | ||
|
||
const delay = () => new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
||
const write = async (inputs = []) => { | ||
for (const input of inputs) { | ||
stdin.write(input); | ||
await delay(); | ||
} | ||
|
||
stdin.end(); | ||
}; | ||
|
||
return { | ||
getResult, | ||
write | ||
}; | ||
}; |
Oops, something went wrong.