|
1 | 1 | import { QualifiedRules, RuleConfigSeverity } from '@commitlint/types';
|
2 |
| -import { red } from 'chalk'; |
| 2 | +import { green, red } from 'chalk'; |
3 | 3 | import {
|
4 | 4 | breakingChangeFilterFactory,
|
5 | 5 | breakingChangeMessageFactory,
|
6 | 6 | breakingTransformFactory,
|
7 | 7 | issueFilterFactory,
|
8 | 8 | issuesMessageFactory,
|
| 9 | + issuesTransformerFactory, |
9 | 10 | } from './footer-maker';
|
10 | 11 |
|
11 | 12 | describe('footerMaker', () => {
|
@@ -69,4 +70,38 @@ describe('footerMaker', () => {
|
69 | 70 | );
|
70 | 71 | });
|
71 | 72 | });
|
| 73 | + |
| 74 | + describe('issuesTransformerFactory', () => { |
| 75 | + describe('with a breaking change', () => { |
| 76 | + it('should show a message in green color when footer has maximum length rule', () => { |
| 77 | + const rules: QualifiedRules = { 'footer-max-length': [RuleConfigSeverity.Error, 'always', 60] }; |
| 78 | + |
| 79 | + const fixture = issuesTransformerFactory(rules); |
| 80 | + |
| 81 | + const result = fixture("If you haven't seen Game of Thrones, go watch it right now.", { |
| 82 | + isBreaking: true, |
| 83 | + breaking: 'Some big change', |
| 84 | + }); |
| 85 | + expect(result).toBe(green("(59) If you haven't seen Game of Thrones, go watch it right now.")); |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + describe('without a breaking change', () => { |
| 90 | + it('should show a message in red color when footer has maximum length rule', () => { |
| 91 | + const rules: QualifiedRules = { 'footer-max-length': [RuleConfigSeverity.Error, 'always', 88] }; |
| 92 | + |
| 93 | + const fixture = issuesTransformerFactory(rules); |
| 94 | + |
| 95 | + const result = fixture( |
| 96 | + "If you haven't seen Game of Thrones, go watch it right now. If you have then you'll totally get why this Hodor themed lorem ipsum generator is just brilliant.", |
| 97 | + { isBreaking: false } |
| 98 | + ); |
| 99 | + expect(result).toBe( |
| 100 | + red( |
| 101 | + "(158) If you haven't seen Game of Thrones, go watch it right now. If you have then you'll totally get why this Hodor themed lorem ipsum generator is just brilliant." |
| 102 | + ) |
| 103 | + ); |
| 104 | + }); |
| 105 | + }); |
| 106 | + }); |
72 | 107 | });
|
0 commit comments