Skip to content

Commit

Permalink
test: readd empty commit message test
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Feb 7, 2020
1 parent a2b627d commit eb05be2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions @commitlint/lint/src/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ test('throws without params', async () => {
});

test('throws with empty message', async () => {
const error = (lint as any)('');
await expect(error).rejects.toThrow('Expected a raw commit');
expect(await lint('')).toMatchObject({
valid: true,
errors: [],
warnings: []
});
});

test('positive on stub message and no rule', async () => {
Expand Down
6 changes: 4 additions & 2 deletions @commitlint/lint/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export default async function lint(
return LintOutcome.empty({message});
}

// Parse the commit message
const parsed = await parse(message, undefined, opts.parserOpts);
const parsed =
message === ''
? {header: null, body: null, footer: null}
: await parse(message, undefined, opts.parserOpts);

if (
parsed.header === null &&
Expand Down

0 comments on commit eb05be2

Please sign in to comment.