Skip to content

Commit edc6fed

Browse files
committed
test: add tests for confirm prompt
1 parent cfe46cf commit edc6fed

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",
@@ -220,6 +369,155 @@ exports[`prompts (isCI = false) > text > renders submitted value 1`] = `
220369
]
221370
`;
222371

372+
exports[`prompts (isCI = true) > confirm > can cancel 1`] = `
373+
[
374+
"[?25l",
375+
"│
376+
◆ foo
377+
│ ● Yes / ○ No
378+
└
379+
",
380+
"",
381+
"",
382+
"",
383+
"■ foo
384+
│ No
385+
│",
386+
"
387+
",
388+
"[?25h",
389+
]
390+
`;
391+
392+
exports[`prompts (isCI = true) > confirm > can set initialValue 1`] = `
393+
[
394+
"[?25l",
395+
"│
396+
◆ foo
397+
│ ○ Yes / ● No
398+
└
399+
",
400+
"",
401+
"",
402+
"",
403+
"◇ foo
404+
│ No",
405+
"
406+
",
407+
"[?25h",
408+
]
409+
`;
410+
411+
exports[`prompts (isCI = true) > confirm > left arrow moves to previous choice 1`] = `
412+
[
413+
"[?25l",
414+
"│
415+
◆ foo
416+
│ ● Yes / ○ No
417+
└
418+
",
419+
"",
420+
"",
421+
"",
422+
"│ ○ Yes / ● No",
423+
"",
424+
"",
425+
"",
426+
"",
427+
"│ ● Yes / ○ No",
428+
"",
429+
"",
430+
"",
431+
"",
432+
"◇ foo
433+
│ Yes",
434+
"
435+
",
436+
"[?25h",
437+
]
438+
`;
439+
440+
exports[`prompts (isCI = true) > confirm > renders custom active choice 1`] = `
441+
[
442+
"[?25l",
443+
"│
444+
◆ foo
445+
│ ● bleep / ○ No
446+
└
447+
",
448+
"",
449+
"",
450+
"",
451+
"◇ foo
452+
│ bleep",
453+
"
454+
",
455+
"[?25h",
456+
]
457+
`;
458+
459+
exports[`prompts (isCI = true) > confirm > renders custom inactive choice 1`] = `
460+
[
461+
"[?25l",
462+
"│
463+
◆ foo
464+
│ ● Yes / ○ bleep
465+
└
466+
",
467+
"",
468+
"",
469+
"",
470+
"◇ foo
471+
│ Yes",
472+
"
473+
",
474+
"[?25h",
475+
]
476+
`;
477+
478+
exports[`prompts (isCI = true) > confirm > renders message with choices 1`] = `
479+
[
480+
"[?25l",
481+
"│
482+
◆ foo
483+
│ ● Yes / ○ No
484+
└
485+
",
486+
"",
487+
"",
488+
"",
489+
"◇ foo
490+
│ Yes",
491+
"
492+
",
493+
"[?25h",
494+
]
495+
`;
496+
497+
exports[`prompts (isCI = true) > confirm > right arrow moves to next choice 1`] = `
498+
[
499+
"[?25l",
500+
"│
501+
◆ foo
502+
│ ● Yes / ○ No
503+
└
504+
",
505+
"",
506+
"",
507+
"",
508+
"│ ○ Yes / ● No",
509+
"",
510+
"",
511+
"",
512+
"",
513+
"◇ foo
514+
│ No",
515+
"
516+
",
517+
"[?25h",
518+
]
519+
`;
520+
223521
exports[`prompts (isCI = true) > spinner > message > sets message for next frame 1`] = `
224522
[
225523
"[?25l",

0 commit comments

Comments
 (0)