From e3a78bc12c464360eb87f36c2989ff71f182b4c9 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Fri, 8 Dec 2017 20:19:27 +0100 Subject: [PATCH] fix(core): use correct report message #192 --- @commitlint/core/src/rules/subject-case.js | 2 +- .../core/src/rules/subject-case.test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/@commitlint/core/src/rules/subject-case.js b/@commitlint/core/src/rules/subject-case.js index 40cc22e560..1b34c85248 100644 --- a/@commitlint/core/src/rules/subject-case.js +++ b/@commitlint/core/src/rules/subject-case.js @@ -29,6 +29,6 @@ export default (parsed, when, value) => { return [ negated(when) ? !result : result, - message([`subject must`, negated ? `not` : null, `be ${list}`]) + message([`subject must`, negated(when) ? `not` : null, `be ${list}`]) ]; }; diff --git a/@commitlint/core/src/rules/subject-case.test.js b/@commitlint/core/src/rules/subject-case.test.js index 2204afdb15..2d263f6a83 100644 --- a/@commitlint/core/src/rules/subject-case.test.js +++ b/@commitlint/core/src/rules/subject-case.test.js @@ -251,3 +251,21 @@ test('with startcase subject should succeed for "always startcase"', async t => const expected = true; t.is(actual, expected); }); + +test('should use expected message with "always"', async t => { + const [, message] = subjectCase( + await parsed.uppercase, + 'always', + 'lower-case' + ); + t.true(message.indexOf('must be lower-case') > -1); +}); + +test('should use expected message with "never"', async t => { + const [, message] = subjectCase( + await parsed.uppercase, + 'never', + 'upper-case' + ); + t.true(message.indexOf('must not be upper-case') > -1); +});