Skip to content

Commit

Permalink
test: improve coverage for subject max header length
Browse files Browse the repository at this point in the history
Previously specifying a custom max header width wasn't actually tested for, only the configuration
loading was tested. This ensures that we have coverage on this functionality.
  • Loading branch information
ThisIsMissEm committed Jul 29, 2020
1 parent 23e0356 commit 1964940
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,42 @@ describe('commit message', function() {
});

describe('validation', function() {
it('subject exceeds max length', function() {
expect(() =>
commitMessage({
type,
scope,
subject: longBody
})
).to.throw(
'length must be less than or equal to ' +
`${defaultOptions.maxLineWidth - type.length - scope.length - 4}`
);
describe('subject exceeds max length', function() {
it('using the default max length', function() {
expect(() =>
commitMessage({
type,
scope,
subject: longBody
})
).to.throw(
'length must be less than or equal to ' +
`${defaultOptions.maxLineWidth - type.length - scope.length - 4}`
);
});

it('using a custom max length', function() {
var customMaxHeaderWidth = 30;

expect(() =>
commitMessage(
{
type,
scope,
subject: longBody
},
{
...defaultOptions,
maxHeaderWidth: customMaxHeaderWidth
}
)
).to.throw(
'length must be less than or equal to ' +
`${customMaxHeaderWidth - type.length - scope.length - 4}`
);
});
});

it('empty subject', function() {
expect(() =>
commitMessage({
Expand Down

0 comments on commit 1964940

Please sign in to comment.