Skip to content

Commit

Permalink
Feat: throw on not valid route
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Sep 6, 2018
1 parent c8361b5 commit 08ea1ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rules/ruleWarningMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const ruleWarningMessages = (input, config) => {

configRuleEntries.forEach((rule) => {
const ruleName = rule[0];

if (!(rules[ruleName] instanceof Function)) {
throw new Error(`The rule '${ruleName}' does not exist, look at the documentation to check valid rules.`);
}

const ruleIs = rules[ruleName](input, config).check();

if (!ruleIs) {
Expand Down
12 changes: 12 additions & 0 deletions test/rules/ruleWarningMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ test('ruleWarningMessages', (t) => {
const messages = ruleWaringMessages('input.', config);
t.deepEqual(messages, 'The commit message has to be at least 10 character, but is only 6 character long.\nThe commit message can not end with a dot\n');
});

test('should throw an error', (t) => {
const config = {
rules: {
notExisting: 10,
},
};

const error = t.throws(() => ruleWaringMessages('input.', config));

t.true(error instanceof Error);
});

0 comments on commit 08ea1ed

Please sign in to comment.