Skip to content

Commit 3e3b148

Browse files
committed
chore: add await to useEvents
1 parent 59845ea commit 3e3b148

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

packages/plop/tests/action-failure.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ test("should exit with code 1 when failed actions", async () => {
1111
cwd: resolve(__dirname, "./examples/action-failure"),
1212
});
1313
expect(await findByText("What is your name?")).toBeInTheConsole();
14-
userEvent.keyboard("Joe");
14+
await userEvent.keyboard("Joe");
1515
expect(await findByText("Joe")).toBeInTheConsole();
16-
userEvent.keyboard("[Enter]");
16+
await userEvent.keyboard("[Enter]");
1717
const actionOutput = await findByText("Action failed");
1818
await waitFor(() =>
1919
expect(actionOutput.hasExit()).toStrictEqual({ exitCode: 1 }),

packages/plop/tests/actions.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ test("Plop to add and rename files", async () => {
1919

2020
expect(await findByText("What should the file name be?")).toBeInTheConsole();
2121

22-
userEvent.keyboard("new-output");
23-
userEvent.keyboard("[Enter]");
22+
await userEvent.keyboard("new-output");
23+
await userEvent.keyboard("[Enter]");
2424

2525
await waitFor(() => fs.promises.stat(expectedFilePath));
2626

@@ -40,8 +40,8 @@ test("Plop to add and change file contents", async () => {
4040

4141
expect(await findByText("What's your name?")).toBeInTheConsole();
4242

43-
userEvent.keyboard("Corbin");
44-
userEvent.keyboard("[Enter]");
43+
await userEvent.keyboard("Corbin");
44+
await userEvent.keyboard("[Enter]");
4545

4646
await waitFor(() => fs.promises.stat(expectedFilePath));
4747

packages/plop/tests/esm.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,37 @@ test("should load ESM file", async () => {
1010
cwd: resolve(__dirname, "./examples/esm"),
1111
});
1212
expect(await findByText("What is your name?")).toBeInTheConsole();
13-
userEvent.keyboard("Joe");
13+
await userEvent.keyboard("Joe");
1414
expect(await findByText("Joe")).toBeInTheConsole();
15-
userEvent.keyboard("[Enter]");
15+
await userEvent.keyboard("[Enter]");
1616
});
1717

1818
test("should load MJS file", async () => {
1919
const { findByText, userEvent } = await renderPlop([], {
2020
cwd: resolve(__dirname, "./examples/mjs"),
2121
});
2222
expect(await findByText("What is your name?")).toBeInTheConsole();
23-
userEvent.keyboard("Joe");
23+
await userEvent.keyboard("Joe");
2424
expect(await findByText("Joe")).toBeInTheConsole();
25-
userEvent.keyboard("[Enter]");
25+
await userEvent.keyboard("[Enter]");
2626
});
2727

2828
test("should load CJS file", async () => {
2929
const { findByText, userEvent } = await renderPlop([], {
3030
cwd: resolve(__dirname, "./examples/cjs"),
3131
});
3232
expect(await findByText("What is your name?")).toBeInTheConsole();
33-
userEvent.keyboard("Joe");
33+
await userEvent.keyboard("Joe");
3434
expect(await findByText("Joe")).toBeInTheConsole();
35-
userEvent.keyboard("[Enter]");
35+
await userEvent.keyboard("[Enter]");
3636
});
3737

3838
test("should load JS module='commonjs' file", async () => {
3939
const { findByText, userEvent } = await renderPlop([], {
4040
cwd: resolve(__dirname, "./examples/cjs-js"),
4141
});
4242
expect(await findByText("What is your name?")).toBeInTheConsole();
43-
userEvent.keyboard("Joe");
43+
await userEvent.keyboard("Joe");
4444
expect(await findByText("Joe")).toBeInTheConsole();
45-
userEvent.keyboard("[Enter]");
45+
await userEvent.keyboard("[Enter]");
4646
});

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ test("should display inquirer prompts", async () => {
3232
cwd: resolve(__dirname, "./examples/prompt-only"),
3333
});
3434
expect(await findByText("What is your name?")).toBeInTheConsole();
35-
userEvent.keyboard("Joe");
35+
await userEvent.keyboard("Joe");
3636
expect(await findByText("Joe")).toBeInTheConsole();
37-
userEvent.keyboard("[Enter]");
37+
await userEvent.keyboard("[Enter]");
3838
});
3939

4040
test("Should handle generator prompt", async () => {
@@ -45,9 +45,9 @@ test("Should handle generator prompt", async () => {
4545
await findByText("Please choose a generator");
4646

4747
clear();
48-
userEvent.keyboard("[ArrowUp]");
49-
userEvent.keyboard("[ArrowDown]");
50-
userEvent.keyboard("[Enter]");
48+
await userEvent.keyboard("[ArrowUp]");
49+
await userEvent.keyboard("[ArrowDown]");
50+
await userEvent.keyboard("[Enter]");
5151

5252
expect(await findByText("this is a test")).toBeInTheConsole();
5353
});
@@ -80,7 +80,7 @@ test("Should bypass input prompt with placeholder", async () => {
8080
);
8181

8282
expect(await findByText("What is your name?")).toBeInTheConsole();
83-
userEvent.keyboard("[Enter]");
83+
await userEvent.keyboard("[Enter]");
8484
expect(
8585
await queryByText("What pizza toppings do you like?"),
8686
).not.toBeInTheConsole();
@@ -142,7 +142,7 @@ test("Should bypass checkbox prompt with name", async () => {
142142
);
143143

144144
expect(await findByText("What is your name?")).toBeInTheConsole();
145-
userEvent.keyboard("[Enter]");
145+
await userEvent.keyboard("[Enter]");
146146
expect(
147147
await queryByText("What pizza toppings do you like?"),
148148
).not.toBeInTheConsole();
@@ -157,7 +157,7 @@ test("Should bypass checkbox prompt with empty string", async () => {
157157
);
158158

159159
expect(await findByText("What is your name?")).toBeInTheConsole();
160-
userEvent.keyboard("[Enter]");
160+
await userEvent.keyboard("[Enter]");
161161
expect(
162162
await queryByText("What pizza toppings do you like?"),
163163
).not.toBeInTheConsole();

plop-templates/plop-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test("should load ESM file", async () => {
1010
cwd: resolve(__dirname, "./examples/esm"),
1111
});
1212
expect(await findByText("What is your name?")).toBeInTheConsole();
13-
userEvent.keyboard("Joe");
13+
await userEvent.keyboard("Joe");
1414
expect(await findByText("Joe")).toBeInTheConsole();
15-
userEvent.keyboard("[Enter]");
15+
await userEvent.keyboard("[Enter]");
1616
});

0 commit comments

Comments
 (0)