Skip to content

Commit dd2c628

Browse files
committed
test: add tests for select prompt
1 parent cfe46cf commit dd2c628

File tree

3 files changed

+397
-2
lines changed

3 files changed

+397
-2
lines changed

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

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

3+
exports[`prompts (isCI = false) > select > can cancel 1`] = `
4+
[
5+
"[?25l",
6+
"│
7+
◆ foo
8+
│ ● opt0
9+
│ ○ opt1
10+
└
11+
",
12+
"",
13+
"",
14+
"",
15+
"■ foo
16+
│ opt0
17+
│",
18+
"
19+
",
20+
"[?25h",
21+
]
22+
`;
23+
24+
exports[`prompts (isCI = false) > select > down arrow selects next option 1`] = `
25+
[
26+
"[?25l",
27+
"│
28+
◆ foo
29+
│ ● opt0
30+
│ ○ opt1
31+
└
32+
",
33+
"",
34+
"",
35+
"",
36+
"│ ○ opt0
37+
│ ● opt1
38+
└
39+
",
40+
"",
41+
"",
42+
"",
43+
"◇ foo
44+
│ opt1",
45+
"
46+
",
47+
"[?25h",
48+
]
49+
`;
50+
51+
exports[`prompts (isCI = false) > select > renders option hints 1`] = `
52+
[
53+
"[?25l",
54+
"│
55+
◆ foo
56+
│ ● opt0 (Hint 0)
57+
│ ○ opt1
58+
└
59+
",
60+
"",
61+
"",
62+
"",
63+
"◇ foo
64+
│ opt0",
65+
"
66+
",
67+
"[?25h",
68+
]
69+
`;
70+
71+
exports[`prompts (isCI = false) > select > renders option labels 1`] = `
72+
[
73+
"[?25l",
74+
"│
75+
◆ foo
76+
│ ● Option 0
77+
│ ○ Option 1
78+
└
79+
",
80+
"",
81+
"",
82+
"",
83+
"◇ foo
84+
│ Option 0",
85+
"
86+
",
87+
"[?25h",
88+
]
89+
`;
90+
91+
exports[`prompts (isCI = false) > select > renders options and message 1`] = `
92+
[
93+
"[?25l",
94+
"│
95+
◆ foo
96+
│ ● opt0
97+
│ ○ opt1
98+
└
99+
",
100+
"",
101+
"",
102+
"",
103+
"◇ foo
104+
│ opt0",
105+
"
106+
",
107+
"[?25h",
108+
]
109+
`;
110+
111+
exports[`prompts (isCI = false) > select > up arrow selects previous option 1`] = `
112+
[
113+
"[?25l",
114+
"│
115+
◆ foo
116+
│ ● opt0
117+
│ ○ opt1
118+
└
119+
",
120+
"",
121+
"",
122+
"",
123+
"│ ○ opt0
124+
│ ● opt1
125+
└
126+
",
127+
"",
128+
"",
129+
"",
130+
"│ ● opt0
131+
│ ○ opt1
132+
└
133+
",
134+
"",
135+
"",
136+
"",
137+
"◇ foo
138+
│ opt0",
139+
"
140+
",
141+
"[?25h",
142+
]
143+
`;
144+
3145
exports[`prompts (isCI = false) > spinner > message > sets message for next frame 1`] = `
4146
[
5147
"[?25l",
@@ -220,6 +362,148 @@ exports[`prompts (isCI = false) > text > renders submitted value 1`] = `
220362
]
221363
`;
222364

365+
exports[`prompts (isCI = true) > select > can cancel 1`] = `
366+
[
367+
"[?25l",
368+
"│
369+
◆ foo
370+
│ ● opt0
371+
│ ○ opt1
372+
└
373+
",
374+
"",
375+
"",
376+
"",
377+
"■ foo
378+
│ opt0
379+
│",
380+
"
381+
",
382+
"[?25h",
383+
]
384+
`;
385+
386+
exports[`prompts (isCI = true) > select > down arrow selects next option 1`] = `
387+
[
388+
"[?25l",
389+
"│
390+
◆ foo
391+
│ ● opt0
392+
│ ○ opt1
393+
└
394+
",
395+
"",
396+
"",
397+
"",
398+
"│ ○ opt0
399+
│ ● opt1
400+
└
401+
",
402+
"",
403+
"",
404+
"",
405+
"◇ foo
406+
│ opt1",
407+
"
408+
",
409+
"[?25h",
410+
]
411+
`;
412+
413+
exports[`prompts (isCI = true) > select > renders option hints 1`] = `
414+
[
415+
"[?25l",
416+
"│
417+
◆ foo
418+
│ ● opt0 (Hint 0)
419+
│ ○ opt1
420+
└
421+
",
422+
"",
423+
"",
424+
"",
425+
"◇ foo
426+
│ opt0",
427+
"
428+
",
429+
"[?25h",
430+
]
431+
`;
432+
433+
exports[`prompts (isCI = true) > select > renders option labels 1`] = `
434+
[
435+
"[?25l",
436+
"│
437+
◆ foo
438+
│ ● Option 0
439+
│ ○ Option 1
440+
└
441+
",
442+
"",
443+
"",
444+
"",
445+
"◇ foo
446+
│ Option 0",
447+
"
448+
",
449+
"[?25h",
450+
]
451+
`;
452+
453+
exports[`prompts (isCI = true) > select > renders options and message 1`] = `
454+
[
455+
"[?25l",
456+
"│
457+
◆ foo
458+
│ ● opt0
459+
│ ○ opt1
460+
└
461+
",
462+
"",
463+
"",
464+
"",
465+
"◇ foo
466+
│ opt0",
467+
"
468+
",
469+
"[?25h",
470+
]
471+
`;
472+
473+
exports[`prompts (isCI = true) > select > up arrow selects previous option 1`] = `
474+
[
475+
"[?25l",
476+
"│
477+
◆ foo
478+
│ ● opt0
479+
│ ○ opt1
480+
└
481+
",
482+
"",
483+
"",
484+
"",
485+
"│ ○ opt0
486+
│ ● opt1
487+
└
488+
",
489+
"",
490+
"",
491+
"",
492+
"│ ● opt0
493+
│ ○ opt1
494+
└
495+
",
496+
"",
497+
"",
498+
"",
499+
"◇ foo
500+
│ opt0",
501+
"
502+
",
503+
"[?25h",
504+
]
505+
`;
506+
223507
exports[`prompts (isCI = true) > spinner > message > sets message for next frame 1`] = `
224508
[
225509
"[?25l",

0 commit comments

Comments
 (0)