Skip to content

test: add tests for confirm prompt #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 298 additions & 0 deletions packages/prompts/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,154 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`prompts (isCI = false) > confirm > can cancel 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"■ foo
│ No
│",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > can set initialValue 1`] = `
[
"[?25l",
"│
◆ foo
│ ○ Yes / ● No
└
",
"",
"",
"",
"◇ foo
│ No",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > left arrow moves to previous choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"│ ○ Yes / ● No",
"",
"",
"",
"",
"│ ● Yes / ○ No",
"",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > renders custom active choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● bleep / ○ No
└
",
"",
"",
"",
"◇ foo
│ bleep",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > renders custom inactive choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ bleep
└
",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > renders message with choices 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > confirm > right arrow moves to next choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"│ ○ Yes / ● No",
"",
"",
"",
"",
"◇ foo
│ No",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = false) > spinner > message > sets message for next frame 1`] = `
[
"[?25l",
Expand Down Expand Up @@ -315,6 +464,155 @@ exports[`prompts (isCI = false) > text > validation errors render and clear 1`]
]
`;

exports[`prompts (isCI = true) > confirm > can cancel 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"■ foo
│ No
│",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > can set initialValue 1`] = `
[
"[?25l",
"│
◆ foo
│ ○ Yes / ● No
└
",
"",
"",
"",
"◇ foo
│ No",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > left arrow moves to previous choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"│ ○ Yes / ● No",
"",
"",
"",
"",
"│ ● Yes / ○ No",
"",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > renders custom active choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● bleep / ○ No
└
",
"",
"",
"",
"◇ foo
│ bleep",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > renders custom inactive choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ bleep
└
",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > renders message with choices 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"◇ foo
│ Yes",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > confirm > right arrow moves to next choice 1`] = `
[
"[?25l",
"│
◆ foo
│ ● Yes / ○ No
└
",
"",
"",
"",
"│ ○ Yes / ● No",
"",
"",
"",
"",
"◇ foo
│ No",
"
",
"[?25h",
]
`;

exports[`prompts (isCI = true) > spinner > message > sets message for next frame 1`] = `
[
"[?25l",
Expand Down
Loading