Skip to content

Commit 684aa82

Browse files
authored
test: add tests for select prompt (#271)
1 parent 88559cc commit 684aa82

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
@@ -149,6 +149,148 @@ exports[`prompts (isCI = false) > confirm > right arrow moves to next choice 1`]
149149
]
150150
`;
151151

152+
exports[`prompts (isCI = false) > select > can cancel 1`] = `
153+
[
154+
"[?25l",
155+
"│
156+
◆ foo
157+
│ ● opt0
158+
│ ○ opt1
159+
└
160+
",
161+
"",
162+
"",
163+
"",
164+
"■ foo
165+
│ opt0
166+
│",
167+
"
168+
",
169+
"[?25h",
170+
]
171+
`;
172+
173+
exports[`prompts (isCI = false) > select > down arrow selects next option 1`] = `
174+
[
175+
"[?25l",
176+
"│
177+
◆ foo
178+
│ ● opt0
179+
│ ○ opt1
180+
└
181+
",
182+
"",
183+
"",
184+
"",
185+
"│ ○ opt0
186+
│ ● opt1
187+
└
188+
",
189+
"",
190+
"",
191+
"",
192+
"◇ foo
193+
│ opt1",
194+
"
195+
",
196+
"[?25h",
197+
]
198+
`;
199+
200+
exports[`prompts (isCI = false) > select > renders option hints 1`] = `
201+
[
202+
"[?25l",
203+
"│
204+
◆ foo
205+
│ ● opt0 (Hint 0)
206+
│ ○ opt1
207+
└
208+
",
209+
"",
210+
"",
211+
"",
212+
"◇ foo
213+
│ opt0",
214+
"
215+
",
216+
"[?25h",
217+
]
218+
`;
219+
220+
exports[`prompts (isCI = false) > select > renders option labels 1`] = `
221+
[
222+
"[?25l",
223+
"│
224+
◆ foo
225+
│ ● Option 0
226+
│ ○ Option 1
227+
└
228+
",
229+
"",
230+
"",
231+
"",
232+
"◇ foo
233+
│ Option 0",
234+
"
235+
",
236+
"[?25h",
237+
]
238+
`;
239+
240+
exports[`prompts (isCI = false) > select > renders options and message 1`] = `
241+
[
242+
"[?25l",
243+
"│
244+
◆ foo
245+
│ ● opt0
246+
│ ○ opt1
247+
└
248+
",
249+
"",
250+
"",
251+
"",
252+
"◇ foo
253+
│ opt0",
254+
"
255+
",
256+
"[?25h",
257+
]
258+
`;
259+
260+
exports[`prompts (isCI = false) > select > up arrow selects previous option 1`] = `
261+
[
262+
"[?25l",
263+
"│
264+
◆ foo
265+
│ ● opt0
266+
│ ○ opt1
267+
└
268+
",
269+
"",
270+
"",
271+
"",
272+
"│ ○ opt0
273+
│ ● opt1
274+
└
275+
",
276+
"",
277+
"",
278+
"",
279+
"│ ● opt0
280+
│ ○ opt1
281+
└
282+
",
283+
"",
284+
"",
285+
"",
286+
"◇ foo
287+
│ opt0",
288+
"
289+
",
290+
"[?25h",
291+
]
292+
`;
293+
152294
exports[`prompts (isCI = false) > spinner > message > sets message for next frame 1`] = `
153295
[
154296
"[?25l",
@@ -613,6 +755,148 @@ exports[`prompts (isCI = true) > confirm > right arrow moves to next choice 1`]
613755
]
614756
`;
615757

758+
exports[`prompts (isCI = true) > select > can cancel 1`] = `
759+
[
760+
"[?25l",
761+
"│
762+
◆ foo
763+
│ ● opt0
764+
│ ○ opt1
765+
└
766+
",
767+
"",
768+
"",
769+
"",
770+
"■ foo
771+
│ opt0
772+
│",
773+
"
774+
",
775+
"[?25h",
776+
]
777+
`;
778+
779+
exports[`prompts (isCI = true) > select > down arrow selects next option 1`] = `
780+
[
781+
"[?25l",
782+
"│
783+
◆ foo
784+
│ ● opt0
785+
│ ○ opt1
786+
└
787+
",
788+
"",
789+
"",
790+
"",
791+
"│ ○ opt0
792+
│ ● opt1
793+
└
794+
",
795+
"",
796+
"",
797+
"",
798+
"◇ foo
799+
│ opt1",
800+
"
801+
",
802+
"[?25h",
803+
]
804+
`;
805+
806+
exports[`prompts (isCI = true) > select > renders option hints 1`] = `
807+
[
808+
"[?25l",
809+
"│
810+
◆ foo
811+
│ ● opt0 (Hint 0)
812+
│ ○ opt1
813+
└
814+
",
815+
"",
816+
"",
817+
"",
818+
"◇ foo
819+
│ opt0",
820+
"
821+
",
822+
"[?25h",
823+
]
824+
`;
825+
826+
exports[`prompts (isCI = true) > select > renders option labels 1`] = `
827+
[
828+
"[?25l",
829+
"│
830+
◆ foo
831+
│ ● Option 0
832+
│ ○ Option 1
833+
└
834+
",
835+
"",
836+
"",
837+
"",
838+
"◇ foo
839+
│ Option 0",
840+
"
841+
",
842+
"[?25h",
843+
]
844+
`;
845+
846+
exports[`prompts (isCI = true) > select > renders options and message 1`] = `
847+
[
848+
"[?25l",
849+
"│
850+
◆ foo
851+
│ ● opt0
852+
│ ○ opt1
853+
└
854+
",
855+
"",
856+
"",
857+
"",
858+
"◇ foo
859+
│ opt0",
860+
"
861+
",
862+
"[?25h",
863+
]
864+
`;
865+
866+
exports[`prompts (isCI = true) > select > up arrow selects previous option 1`] = `
867+
[
868+
"[?25l",
869+
"│
870+
◆ foo
871+
│ ● opt0
872+
│ ○ opt1
873+
└
874+
",
875+
"",
876+
"",
877+
"",
878+
"│ ○ opt0
879+
│ ● opt1
880+
└
881+
",
882+
"",
883+
"",
884+
"",
885+
"│ ● opt0
886+
│ ○ opt1
887+
└
888+
",
889+
"",
890+
"",
891+
"",
892+
"◇ foo
893+
│ opt0",
894+
"
895+
",
896+
"[?25h",
897+
]
898+
`;
899+
616900
exports[`prompts (isCI = true) > spinner > message > sets message for next frame 1`] = `
617901
[
618902
"[?25l",

0 commit comments

Comments
 (0)