Skip to content

Commit 92f82fe

Browse files
committed
add tests for note component
1 parent a29d067 commit 92f82fe

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,32 @@ exports[`note (isCI = false) > formatter which adds length works 1`] = `
9898
]
9999
`;
100100

101+
exports[`note (isCI = false) > handle wide characters 1`] = `
102+
[
103+
"│
104+
◇ 这是标题 ──────────────╮
105+
│ │
106+
│ 이게 첫 번째 줄이에요 │
107+
│ これは次の行です │
108+
│ │
109+
├─────────────────────────╯
110+
",
111+
]
112+
`;
113+
114+
exports[`note (isCI = false) > handle wide characters with formatter 1`] = `
115+
[
116+
"│
117+
◇ 这是标题 ──────────────────╮
118+
│ │
119+
│ * 이게 첫 번째 줄이에요 * │
120+
│ * これは次の行です * │
121+
│ │
122+
├─────────────────────────────╯
123+
",
124+
]
125+
`;
126+
101127
exports[`note (isCI = false) > renders as wide as longest line 1`] = `
102128
[
103129
"│
@@ -221,6 +247,32 @@ exports[`note (isCI = true) > formatter which adds length works 1`] = `
221247
]
222248
`;
223249

250+
exports[`note (isCI = true) > handle wide characters 1`] = `
251+
[
252+
"│
253+
◇ 这是标题 ──────────────╮
254+
│ │
255+
│ 이게 첫 번째 줄이에요 │
256+
│ これは次の行です │
257+
│ │
258+
├─────────────────────────╯
259+
",
260+
]
261+
`;
262+
263+
exports[`note (isCI = true) > handle wide characters with formatter 1`] = `
264+
[
265+
"│
266+
◇ 这是标题 ──────────────────╮
267+
│ │
268+
│ * 이게 첫 번째 줄이에요 * │
269+
│ * これは次の行です * │
270+
│ │
271+
├─────────────────────────────╯
272+
",
273+
]
274+
`;
275+
224276
exports[`note (isCI = true) > renders as wide as longest line 1`] = `
225277
[
226278
"│

packages/prompts/test/note.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,31 @@ describe.each(['true', 'false'])('note (isCI = %s)', (isCI) => {
8484

8585
expect(output.buffer).toMatchSnapshot();
8686
});
87+
88+
test("handle wide characters", () => {
89+
const messages = [
90+
'이게 첫 번째 줄이에요',
91+
'これは次の行です',
92+
];
93+
prompts.note(messages.join("\n"), '这是标题', {
94+
input,
95+
output: Object.assign(output, { columns: 10 }),
96+
});
97+
98+
expect(output.buffer).toMatchSnapshot();
99+
});
100+
101+
test("handle wide characters with formatter", () => {
102+
const messages = [
103+
'이게 첫 번째 줄이에요',
104+
'これは次の行です',
105+
];
106+
prompts.note(messages.join("\n"), '这是标题', {
107+
format: (line) => colors.red(`* ${colors.cyan(line)} *`),
108+
input,
109+
output: Object.assign(output, { columns: 10 }),
110+
});
111+
112+
expect(output.buffer).toMatchSnapshot();
113+
});
87114
});

0 commit comments

Comments
 (0)