Skip to content

Commit f988f44

Browse files
committed
test: add footer-maker breakingTransformFactory test
1 parent 9c36634 commit f988f44

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/prompts/footer-maker.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { QualifiedRules, RuleConfigSeverity } from '@commitlint/types';
2+
import { red } from 'chalk';
23
import {
34
breakingChangeFilterFactory,
45
breakingChangeMessageFactory,
6+
breakingTransformFactory,
57
issueFilterFactory,
68
issuesMessageFactory,
79
} from './footer-maker';
@@ -50,4 +52,21 @@ describe('footerMaker', () => {
5052
expect(result).toBe('Add issue references (e.g. "fix #123", "re #123".) (max 88 chars):\n');
5153
});
5254
});
55+
56+
describe('breakingTransformFactory', () => {
57+
it('should show a message in red color when footer has maximum length rule', () => {
58+
const rules: QualifiedRules = { 'footer-max-length': [RuleConfigSeverity.Error, 'always', 88] };
59+
60+
const fixture = breakingTransformFactory(rules, 'BREAKING CHANGE: ');
61+
62+
const result = fixture(
63+
'The coverage has decreased with this PR, please add tests for the additional functions to at least bring the coverage to the same percentage.'
64+
);
65+
expect(result).toBe(
66+
red(
67+
'(141) The coverage has decreased with this PR, please add tests for the additional functions to at least bring the coverage to the same percentage.'
68+
)
69+
);
70+
});
71+
});
5372
});

0 commit comments

Comments
 (0)