Skip to content

Commit

Permalink
Chore: prevent breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Mar 27, 2019
1 parent 93fa8cc commit 40a655b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
7 changes: 0 additions & 7 deletions .sgcrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
"message": "Initial commit"
},
"types": [
{
"emoji": ":wrench:",
"type": false,
"description": "A custom type with prefix",
"prefix": "SGC-",
"argKeys": ["cu", "custom"]
},
{
"emoji": ":wrench:",
"type": "Chore:",
Expand Down
31 changes: 31 additions & 0 deletions test/fixtures/.sgcrc.customType
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"scope": false,
"body": true,
"emoji": false,
"lowercaseTypes": false,
"initialCommit": {
"isEnabled": true,
"emoji": ":tada:",
"message": "Initial commit"
},
"types": [
{
"emoji": ":wrench:",
"type": false,
"description": "A custom type with prefix",
"prefix": "SGC-",
"argKeys": ["cu", "custom"]
},
{
"emoji": ":wrench:",
"type": false,
"description": "Another custom type with prefix",
"prefix": "SGGC-"
}
],
"rules": {
"maxChar": 72,
"minChar": 10,
"endWithDot": false
}
}
14 changes: 7 additions & 7 deletions test/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test('choices are rendered with emoji (default)', (t) => {
});

test('choices are rendered as custom type', (t) => {
const sgc = getConfig();
const sgc = getConfig(path.join(fixtures, '.sgcrc.customType'));

sgc.emoji = false;
sgc.types[0].type = false;
Expand Down Expand Up @@ -173,31 +173,31 @@ test('SCOPE | check if scope is off by default', (t) => {
});

test('CUSTOMTYPE | check if customType gets shown when type is defined', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));
const questionsList = questions(config);

t.is(questionsList[questionsListOrder.customType].when({ type: 'Feat:' }), false);
t.is(questionsList[questionsListOrder.customType].when({ type: 'anything' }), false);
});

test('CUSTOMTYPE | check if customType gets shown when type is custom', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));
const questionsList = questions(config);

t.is(questionsList[questionsListOrder.customType].when({ type: customName }), true);
t.is(questionsList[questionsListOrder.customType].when({ type: `${customName}feat` }), true);
});

test('CUSTOMTYPE | should not show when argv is specified', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));
const questionsList = questions(config, { c: 'Feat:' });

t.is(questionsList[questionsListOrder.customType].when({ type: customName }), false);
t.is(questionsList[questionsListOrder.customType].when({ type: `${customName}feat` }), false);
});

test('CUSTOMTYPE | return prefixed answer', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));

config.types[0].prefix = 'myprefix';

Expand All @@ -207,7 +207,7 @@ test('CUSTOMTYPE | return prefixed answer', (t) => {
});

test('CUSTOMTYPE | return nonprefixed answer', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));

config.types[0].prefix = undefined;

Expand All @@ -217,7 +217,7 @@ test('CUSTOMTYPE | return nonprefixed answer', (t) => {
});

test('CUSTOMTYPE | return any type', (t) => {
const config = getConfig();
const config = getConfig(path.join(fixtures, '.sgcrc.customType'));
const questionsList = questions(config);

t.is(questionsList[questionsListOrder.customType].filter('something', { type: 'none' }), 'something');
Expand Down

0 comments on commit 40a655b

Please sign in to comment.