Skip to content

Commit 93c3d1d

Browse files
committed
test: add tests for confirm prompt
1 parent 68bbf74 commit 93c3d1d

File tree

2 files changed

+411
-0
lines changed

2 files changed

+411
-0
lines changed

packages/prompts/src/__snapshots__/index.test.ts.snap

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,154 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`prompts (isCI = false) > confirm > can cancel 1`] = `
4+
[
5+
"[?25l",
6+
"│
7+
◆ foo
8+
│ ● Yes / ○ No
9+
└
10+
",
11+
"",
12+
"",
13+
"",
14+
"■ foo
15+
│ No
16+
│",
17+
"
18+
",
19+
"[?25h",
20+
]
21+
`;
22+
23+
exports[`prompts (isCI = false) > confirm > can set initialValue 1`] = `
24+
[
25+
"[?25l",
26+
"│
27+
◆ foo
28+
│ ○ Yes / ● No
29+
└
30+
",
31+
"",
32+
"",
33+
"",
34+
"◇ foo
35+
│ No",
36+
"
37+
",
38+
"[?25h",
39+
]
40+
`;
41+
42+
exports[`prompts (isCI = false) > confirm > left arrow moves to previous choice 1`] = `
43+
[
44+
"[?25l",
45+
"│
46+
◆ foo
47+
│ ● Yes / ○ No
48+
└
49+
",
50+
"",
51+
"",
52+
"",
53+
"│ ○ Yes / ● No",
54+
"",
55+
"",
56+
"",
57+
"",
58+
"│ ● Yes / ○ No",
59+
"",
60+
"",
61+
"",
62+
"",
63+
"◇ foo
64+
│ Yes",
65+
"
66+
",
67+
"[?25h",
68+
]
69+
`;
70+
71+
exports[`prompts (isCI = false) > confirm > renders custom active choice 1`] = `
72+
[
73+
"[?25l",
74+
"│
75+
◆ foo
76+
│ ● bleep / ○ No
77+
└
78+
",
79+
"",
80+
"",
81+
"",
82+
"◇ foo
83+
│ bleep",
84+
"
85+
",
86+
"[?25h",
87+
]
88+
`;
89+
90+
exports[`prompts (isCI = false) > confirm > renders custom inactive choice 1`] = `
91+
[
92+
"[?25l",
93+
"│
94+
◆ foo
95+
│ ● Yes / ○ bleep
96+
└
97+
",
98+
"",
99+
"",
100+
"",
101+
"◇ foo
102+
│ Yes",
103+
"
104+
",
105+
"[?25h",
106+
]
107+
`;
108+
109+
exports[`prompts (isCI = false) > confirm > renders message with choices 1`] = `
110+
[
111+
"[?25l",
112+
"│
113+
◆ foo
114+
│ ● Yes / ○ No
115+
└
116+
",
117+
"",
118+
"",
119+
"",
120+
"◇ foo
121+
│ Yes",
122+
"
123+
",
124+
"[?25h",
125+
]
126+
`;
127+
128+
exports[`prompts (isCI = false) > confirm > right arrow moves to next choice 1`] = `
129+
[
130+
"[?25l",
131+
"│
132+
◆ foo
133+
│ ● Yes / ○ No
134+
└
135+
",
136+
"",
137+
"",
138+
"",
139+
"│ ○ Yes / ● No",
140+
"",
141+
"",
142+
"",
143+
"",
144+
"◇ foo
145+
│ No",
146+
"
147+
",
148+
"[?25h",
149+
]
150+
`;
151+
3152
exports[`prompts (isCI = false) > spinner > message > sets message for next frame 1`] = `
4153
[
5154
"[?25l",
@@ -315,6 +464,155 @@ exports[`prompts (isCI = false) > text > validation errors render and clear 1`]
315464
]
316465
`;
317466

467+
exports[`prompts (isCI = true) > confirm > can cancel 1`] = `
468+
[
469+
"[?25l",
470+
"│
471+
◆ foo
472+
│ ● Yes / ○ No
473+
└
474+
",
475+
"",
476+
"",
477+
"",
478+
"■ foo
479+
│ No
480+
│",
481+
"
482+
",
483+
"[?25h",
484+
]
485+
`;
486+
487+
exports[`prompts (isCI = true) > confirm > can set initialValue 1`] = `
488+
[
489+
"[?25l",
490+
"│
491+
◆ foo
492+
│ ○ Yes / ● No
493+
└
494+
",
495+
"",
496+
"",
497+
"",
498+
"◇ foo
499+
│ No",
500+
"
501+
",
502+
"[?25h",
503+
]
504+
`;
505+
506+
exports[`prompts (isCI = true) > confirm > left arrow moves to previous choice 1`] = `
507+
[
508+
"[?25l",
509+
"│
510+
◆ foo
511+
│ ● Yes / ○ No
512+
└
513+
",
514+
"",
515+
"",
516+
"",
517+
"│ ○ Yes / ● No",
518+
"",
519+
"",
520+
"",
521+
"",
522+
"│ ● Yes / ○ No",
523+
"",
524+
"",
525+
"",
526+
"",
527+
"◇ foo
528+
│ Yes",
529+
"
530+
",
531+
"[?25h",
532+
]
533+
`;
534+
535+
exports[`prompts (isCI = true) > confirm > renders custom active choice 1`] = `
536+
[
537+
"[?25l",
538+
"│
539+
◆ foo
540+
│ ● bleep / ○ No
541+
└
542+
",
543+
"",
544+
"",
545+
"",
546+
"◇ foo
547+
│ bleep",
548+
"
549+
",
550+
"[?25h",
551+
]
552+
`;
553+
554+
exports[`prompts (isCI = true) > confirm > renders custom inactive choice 1`] = `
555+
[
556+
"[?25l",
557+
"│
558+
◆ foo
559+
│ ● Yes / ○ bleep
560+
└
561+
",
562+
"",
563+
"",
564+
"",
565+
"◇ foo
566+
│ Yes",
567+
"
568+
",
569+
"[?25h",
570+
]
571+
`;
572+
573+
exports[`prompts (isCI = true) > confirm > renders message with choices 1`] = `
574+
[
575+
"[?25l",
576+
"│
577+
◆ foo
578+
│ ● Yes / ○ No
579+
└
580+
",
581+
"",
582+
"",
583+
"",
584+
"◇ foo
585+
│ Yes",
586+
"
587+
",
588+
"[?25h",
589+
]
590+
`;
591+
592+
exports[`prompts (isCI = true) > confirm > right arrow moves to next choice 1`] = `
593+
[
594+
"[?25l",
595+
"│
596+
◆ foo
597+
│ ● Yes / ○ No
598+
└
599+
",
600+
"",
601+
"",
602+
"",
603+
"│ ○ Yes / ● No",
604+
"",
605+
"",
606+
"",
607+
"",
608+
"◇ foo
609+
│ No",
610+
"
611+
",
612+
"[?25h",
613+
]
614+
`;
615+
318616
exports[`prompts (isCI = true) > spinner > message > sets message for next frame 1`] = `
319617
[
320618
"[?25l",

0 commit comments

Comments
 (0)