From 615748657aaf5c0b5d19c7ff046346a29275ed81 Mon Sep 17 00:00:00 2001 From: Elvin Date: Tue, 15 Jul 2025 19:35:03 -0400 Subject: Update MaxSizedBox.tsx (#2233) Co-authored-by: Jacob Richman Co-authored-by: Scott Densmore Co-authored-by: Pascal Birchler --- .../src/ui/components/shared/MaxSizedBox.test.tsx | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx') diff --git a/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx b/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx index 50951b4f..92147d3c 100644 --- a/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx +++ b/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx @@ -248,6 +248,89 @@ Line 3`); 🐶`); }); + it('falls back to an ellipsis when width is extremely small', () => { + const { lastFrame } = render( + + + + No + wrap + + + , + ); + + expect(lastFrame()).equals('N…'); + }); + + it('truncates long non-wrapping text with ellipsis', () => { + const { lastFrame } = render( + + + + ABCDE + wrap + + + , + ); + + expect(lastFrame()).equals('AB…'); + }); + + it('truncates non-wrapping text containing line breaks', () => { + const { lastFrame } = render( + + + + {'A\nBCDE'} + wrap + + + , + ); + + expect(lastFrame()).equals(`A\n…`); + }); + + it('truncates emoji characters correctly with ellipsis', () => { + const { lastFrame } = render( + + + + 🐶🐶🐶 + wrap + + + , + ); + + expect(lastFrame()).equals(`🐶…`); + }); + + it('shows ellipsis for multiple rows with long non-wrapping text', () => { + const { lastFrame } = render( + + + + AAA + first + + + BBB + second + + + CCC + third + + + , + ); + + expect(lastFrame()).equals(`AA…\nBB…\nCC…`); + }); + it('accounts for additionalHiddenLinesCount', () => { const { lastFrame } = render( -- cgit v1.2.3