Skip to content

Commit ec7af36

Browse files
committed
add tests for box component
1 parent 92f82fe commit ec7af36

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

packages/prompts/test/__snapshots__/box.test.ts.snap

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,38 @@ exports[`box (isCI = false) > renders truncated long titles 1`] = `
191191
]
192192
`;
193193

194+
exports[`box (isCI = false) > renders wide characters with auto width 1`] = `
195+
[
196+
"┌─这是标题─────────────────┐
197+
",
198+
"│ 이게 첫 번째 줄이에요 │
199+
",
200+
"│ これは次の行です │
201+
",
202+
"└──────────────────────────┘
203+
",
204+
]
205+
`;
206+
207+
exports[`box (isCI = false) > renders wide characters with specified width 1`] = `
208+
[
209+
"┌─这是标题─────┐
210+
",
211+
"│ 이게 첫 │
212+
",
213+
"│ 번째 │
214+
",
215+
"│ 줄이에요 │
216+
",
217+
"│ これは次の │
218+
",
219+
"│ 行です │
220+
",
221+
"└──────────────┘
222+
",
223+
]
224+
`;
225+
194226
exports[`box (isCI = false) > renders with formatBorder formatting 1`] = `
195227
[
196228
"┌─title──────┐
@@ -423,6 +455,38 @@ exports[`box (isCI = true) > renders truncated long titles 1`] = `
423455
]
424456
`;
425457

458+
exports[`box (isCI = true) > renders wide characters with auto width 1`] = `
459+
[
460+
"┌─这是标题─────────────────┐
461+
",
462+
"│ 이게 첫 번째 줄이에요 │
463+
",
464+
"│ これは次の行です │
465+
",
466+
"└──────────────────────────┘
467+
",
468+
]
469+
`;
470+
471+
exports[`box (isCI = true) > renders wide characters with specified width 1`] = `
472+
[
473+
"┌─这是标题─────┐
474+
",
475+
"│ 이게 첫 │
476+
",
477+
"│ 번째 │
478+
",
479+
"│ 줄이에요 │
480+
",
481+
"│ これは次の │
482+
",
483+
"│ 行です │
484+
",
485+
"└──────────────┘
486+
",
487+
]
488+
`;
489+
426490
exports[`box (isCI = true) > renders with formatBorder formatting 1`] = `
427491
[
428492
"┌─title──────┐

packages/prompts/test/box.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,32 @@ describe.each(['true', 'false'])('box (isCI = %s)', (isCI) => {
234234

235235
expect(output.buffer).toMatchSnapshot();
236236
});
237+
238+
test('renders wide characters with auto width', () => {
239+
const messages = [
240+
'이게 첫 번째 줄이에요',
241+
'これは次の行です',
242+
];
243+
prompts.box(messages.join("\n"), '这是标题', {
244+
input,
245+
output,
246+
width: 'auto',
247+
});
248+
249+
expect(output.buffer).toMatchSnapshot();
250+
});
251+
252+
test('renders wide characters with specified width', () => {
253+
const messages = [
254+
'이게 첫 번째 줄이에요',
255+
'これは次の行です',
256+
];
257+
prompts.box(messages.join("\n"), '这是标题', {
258+
input,
259+
output,
260+
width: 0.2,
261+
});
262+
263+
expect(output.buffer).toMatchSnapshot();
264+
});
237265
});

0 commit comments

Comments
 (0)