Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
test: ✅ update 📸️ for new cli; add new test for theme gitmoji
Browse files Browse the repository at this point in the history
I _was_ going to rewrite the tests to pull from configuration files
however are these hard-coded at the moment because they should not be?
  • Loading branch information
JeromeFitz committed Feb 28, 2021
1 parent 2227b00 commit 1f032ee
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/parseArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const helpScreen = `
-v, --version print version info and exit
--disable-emoji don't add emoji to commit title
--format custom formatting options for subject
--theme custm them override (default|gitmoji)
--theme custom them override (default|gitmoji)
--non-interactive run git-cz in non-interactive mode
non-interactive mode options:
Expand Down
2 changes: 1 addition & 1 deletion lib/themes/gitmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const rewrites = [
{from: 'passport-control', to: 'roles'},
{from: 'adhesive-bandage', to: 'patch'},
{from: 'monocle-face', to: 'data'},
{from: 'coffin', to: 'remove'},
{from: 'coffin', to: 'rip'},
];

const list = ['chore'];
Expand Down
1 change: 1 addition & 0 deletions test/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`git-cz --help 1`] = `
-v, --version print version info and exit
--disable-emoji don't add emoji to commit title
--format custom formatting options for subject
--theme custom them override (default|gitmoji)
--non-interactive run git-cz in non-interactive mode
non-interactive mode options:
Expand Down
64 changes: 64 additions & 0 deletions test/formatCommitMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaultConfig = {
minMessageLength: 3,
questions: ['type', 'scope', 'subject', 'body', 'breaking', 'issues', 'lerna'],
scopes: [],
theme: 'default',
types: {
chore: {
description: 'Build process or auxiliary tool changes',
Expand Down Expand Up @@ -68,6 +69,35 @@ const defaultConfig = {
},
};

const themeTypes = {
gitmoji: {
chore: {
code: ':computer_disk:',
description: 'Changes that don’t modify src or test files',
emoji: '💽️',
entity: '💽',
hidden: false,
name: 'computer-disk',
release: null,
section: 'Changes that don’t modify src or test files',
semver: null,
value: 'chore',
},
rip: {
code: ':coffin:',
description: 'Remove dead code.',
emoji: '⚰️',
entity: '⚰',
hidden: false,
name: 'coffin',
release: null,
section: 'Remove dead code.',
semver: null,
value: 'rip',
},
},
};

const defaultState = {
answers: {
body: '',
Expand Down Expand Up @@ -145,4 +175,38 @@ describe('formatCommitMessage()', () => {

expect(message).equal('First commit :(init)feat [skip ci]');
});

it('theme => gitmoji (no difference with feat)', () => {
const theme = 'gitmoji';
const message = formatCommitMessage({
...defaultState,
config: {
...defaultConfig,
disableEmoji: true,
theme,
},
});

expect(message).equal('feat: First commit');
});

it('theme => gitmoji (unique type)', () => {
const theme = 'gitmoji';
const message = formatCommitMessage({
...defaultState,
answers: {
...defaultState.answers,
subject: 'Last commit',
type: 'rip',
},
config: {
...defaultConfig,
disableEmoji: true,
theme,
types: themeTypes[theme],
},
});

expect(message).equal('rip: Last commit');
});
});

0 comments on commit 1f032ee

Please sign in to comment.