Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 4101fc1

Browse files
author
Charlike Mike Reagent
committed
fix: ensurances for falsey values
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
1 parent 91d3b48 commit 4101fc1

File tree

10 files changed

+17
-8
lines changed

10 files changed

+17
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"docs": "docks --outfile .verb.md && verb",
88
"lint": "eslint '**/*.js' --cache --fix --quiet --format codeframe",
99
"test": "nyc asia",
10+
"test-only": "asia -r esm -u",
1011
"commit": "yarn lint && yarn test && yarn dry",
1112
"dry": "git add -A && git status --porcelain && gitcommit -sS",
1213
"release": "tunnckocore-release",

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export function validate(commits, ret = false) {
211211
export function check(commits, flat) {
212212
const result = []
213213
.concat(commits)
214-
.filter(Boolean)
214+
.filter((x) => x !== null || x !== undefined)
215215
.reduce((acc, commit) => {
216216
if (typeof commit === 'string') {
217217
commit = parseCommit(commit); // eslint-disable-line no-param-reassign

test/commit/snapshots/check.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/commit/snapshots/parse.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/commit/snapshots/stringify.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/header/snapshots/check.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/header/snapshots/parse.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/main/check.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@ test('should check(object|array) return array even with flat=true, if more than
4545
footer: null,
4646
});
4747
});
48+
49+
test("should check('') fail when empty string given", (t) => {
50+
t.throws(() => check(''), TypeError);
51+
t.throws(() => check(''), /expect `commit` to be non empty string/);
52+
});
53+
test('should check fail on false values, correctly', (t) => {
54+
t.throws(() => check(), TypeError);
55+
t.throws(() => check(), /expect `commit` to be an object/);
56+
57+
t.throws(() => check(undefined), TypeError);
58+
t.throws(() => check(undefined), /expect `commit` to be an object/);
59+
60+
t.throws(() => check(null), TypeError);
61+
t.throws(() => check(null), /expect `commit` to be an object/);
62+
});

test/main/snapshots/check.test.snapshot.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)