Skip to content

Commit 14e259f

Browse files
committed
Allows for empty checkbox selection bypass. Adds test for empty checkbox selection bypass.
1 parent 4433a20 commit 14e259f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/node-plop/src/prompt-bypass.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ const typeBypass = {
8080
throw Error("invalid input");
8181
},
8282
checkbox(v, prompt) {
83+
if (v === "") {
84+
return [];
85+
}
86+
8387
const valList = v.split(",");
8488
const valuesNoMatch = valList.filter(
8589
(val) => !prompt.choices.some((c, idx) => choiceMatchesValue(c, idx, val))

packages/node-plop/tests/prompt-bypass-checkbox/prompt-bypass-checkbox.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ describe("prompt-bypass-checkbox", function () {
6666
);
6767
expect(Array.isArray(someAnswersByMixed.checkbox)).toBe(true);
6868
expect(JSON.stringify(someAnswersByMixed.checkbox)).toBe('["one","three"]');
69+
70+
const [, noAnswers] = await promptBypass(prompts, [""], plop);
71+
expect(Array.isArray(noAnswers.checkbox)).toBe(true);
72+
expect(JSON.stringify(noAnswers.checkbox)).toBe("[]");
6973
});
7074

7175
test("verify bad bypass input", async function () {

0 commit comments

Comments
 (0)