Skip to content

Commit 3051b20

Browse files
committed
test: add footer-maker issuesTransformerFactory test
1 parent f988f44 commit 3051b20

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/prompts/footer-maker.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { QualifiedRules, RuleConfigSeverity } from '@commitlint/types';
2-
import { red } from 'chalk';
2+
import { green, red } from 'chalk';
33
import {
44
breakingChangeFilterFactory,
55
breakingChangeMessageFactory,
66
breakingTransformFactory,
77
issueFilterFactory,
88
issuesMessageFactory,
9+
issuesTransformerFactory,
910
} from './footer-maker';
1011

1112
describe('footerMaker', () => {
@@ -69,4 +70,38 @@ describe('footerMaker', () => {
6970
);
7071
});
7172
});
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+
});
72107
});

0 commit comments

Comments
 (0)