Skip to content

Commit ddccf35

Browse files
committed
Adds tests for checkbox prompt bypassing.
1 parent 14e259f commit ddccf35

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

packages/plop/tests/input-processing.spec.js

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test("Should bypass generator prompt", async () => {
6060
expect(await findByText("What is your name?")).toBeInTheConsole();
6161
});
6262

63-
test("Should bypass prompt by input", async () => {
63+
test("Should bypass input prompt with input", async () => {
6464
const { queryByText, findByText } = await renderPlop(["Frank"], {
6565
cwd: resolve(__dirname, "./examples/prompt-only"),
6666
});
@@ -71,7 +71,7 @@ test("Should bypass prompt by input", async () => {
7171
).toBeInTheConsole();
7272
});
7373

74-
test("Should bypass prompt by input placeholder", async () => {
74+
test("Should bypass input prompt with placeholder", async () => {
7575
const { queryByText, findByText, userEvent } = await renderPlop(
7676
["_", "Cheese"],
7777
{
@@ -86,7 +86,7 @@ test("Should bypass prompt by input placeholder", async () => {
8686
).not.toBeInTheConsole();
8787
});
8888

89-
test("Should bypass prompt by name", async () => {
89+
test("Should bypass input prompt with name", async () => {
9090
const { queryByText, findByText } = await renderPlop(
9191
["--", "--name", "Frank"],
9292
{
@@ -100,7 +100,7 @@ test("Should bypass prompt by name", async () => {
100100
).toBeInTheConsole();
101101
});
102102

103-
test("Should allow for empty string bypassing", async () => {
103+
test("Should bypass input prompt with empty string", async () => {
104104
const { queryByText, findByText } = await renderPlop(["--", "--name", `""`], {
105105
cwd: resolve(__dirname, "./examples/prompt-only"),
106106
});
@@ -111,4 +111,56 @@ test("Should allow for empty string bypassing", async () => {
111111
).toBeInTheConsole();
112112
});
113113

114+
test("Should bypass checkbox prompt with input", async () => {
115+
const { queryByText } = await renderPlop(["Frank", "Cheese"], {
116+
cwd: resolve(__dirname, "./examples/prompt-only"),
117+
});
118+
119+
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
120+
expect(
121+
await queryByText("What pizza toppings do you like?")
122+
).not.toBeInTheConsole();
123+
});
124+
125+
test("Should bypass checkbox prompt with placeholder", async () => {
126+
const { queryByText, findByText } = await renderPlop(["Frank", "_"], {
127+
cwd: resolve(__dirname, "./examples/prompt-only"),
128+
});
129+
130+
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
131+
expect(
132+
await findByText("What pizza toppings do you like?")
133+
).toBeInTheConsole();
134+
});
135+
136+
test("Should bypass checkbox prompt with name", async () => {
137+
const { queryByText, findByText, userEvent } = await renderPlop(
138+
["--", "--toppings", "Cheese"],
139+
{
140+
cwd: resolve(__dirname, "./examples/prompt-only"),
141+
}
142+
);
143+
144+
expect(await findByText("What is your name?")).toBeInTheConsole();
145+
userEvent.keyboard("[Enter]");
146+
expect(
147+
await queryByText("What pizza toppings do you like?")
148+
).not.toBeInTheConsole();
149+
});
150+
151+
test("Should bypass checkbox prompt with empty string", async () => {
152+
const { queryByText, findByText, userEvent } = await renderPlop(
153+
["--", "--toppings", `""`],
154+
{
155+
cwd: resolve(__dirname, "./examples/prompt-only"),
156+
}
157+
);
158+
159+
expect(await findByText("What is your name?")).toBeInTheConsole();
160+
userEvent.keyboard("[Enter]");
161+
expect(
162+
await queryByText("What pizza toppings do you like?")
163+
).not.toBeInTheConsole();
164+
});
165+
114166
test.todo("Dynamic actions");

0 commit comments

Comments
 (0)