-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add TypeScript tests and update example
- Loading branch information
1 parent
ec2ebe1
commit 6caff14
Showing
14 changed files
with
63 additions
and
261 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.js | ||
.map | ||
.nyc_output | ||
node_modules |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NodePlopAPI } from "plop"; | ||
|
||
module.exports = function (plop: NodePlopAPI) { | ||
plop.setGenerator("test", { | ||
description: "this is a test", | ||
prompts: [ | ||
{ | ||
type: "input", | ||
name: "name", | ||
message: "What is your name?", | ||
validate: function (value) { | ||
if (/.+/.test(value)) { | ||
return true; | ||
} | ||
return "name is required"; | ||
}, | ||
}, | ||
{ | ||
type: "checkbox", | ||
name: "toppings", | ||
message: "What pizza toppings do you like?", | ||
choices: [ | ||
{ name: "Cheese", value: "cheese", checked: true }, | ||
{ name: "Pepperoni", value: "pepperoni" }, | ||
{ name: "Pineapple", value: "pineapple" }, | ||
{ name: "Mushroom", value: "mushroom" }, | ||
{ name: "Bacon", value: "bacon", checked: true }, | ||
], | ||
}, | ||
], | ||
}); | ||
}; |
4 changes: 2 additions & 2 deletions
4
...ges/plop/example/typescript/tsconfig.json → ...p/tests/examples/typescript/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { resolve, dirname } from "node:path"; | ||
import { waitFor } from "cli-testing-library"; | ||
import { renderScript } from "./render.js"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
const renderWrapper = (...props) => { | ||
return renderScript( | ||
resolve(__dirname, "./examples/wrap-plop/index.js"), | ||
...props | ||
); | ||
}; | ||
|
||
test("wrapper should prompts", async () => { | ||
const props = await renderScript("yarn", ["tsc"], { | ||
cwd: resolve(__dirname, "./examples/typescript"), | ||
}); | ||
await waitFor(() => props.hasExit()); | ||
const { findByText } = await renderWrapper([""], { | ||
cwd: resolve(__dirname, "./examples/typescript"), | ||
}); | ||
|
||
expect(await findByText("What is your name?")).toBeInTheConsole(); | ||
}); |