summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/shared/text-buffer.test.ts
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-08-13 17:33:01 -0700
committerGitHub <[email protected]>2025-08-14 00:33:01 +0000
commit342820cf5e0c6ee34d675dd5311d2f7147bc0494 (patch)
treeafd1d89dba7a267dbafb27ab02d2e465802d055e /packages/cli/src/ui/components/shared/text-buffer.test.ts
parent6d01ba65a2f720b6765ae4328e2b8cf46f725589 (diff)
Fix/emoji support (#6187)
Co-authored-by: elasticdotventures <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/components/shared/text-buffer.test.ts')
-rw-r--r--packages/cli/src/ui/components/shared/text-buffer.test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/shared/text-buffer.test.ts b/packages/cli/src/ui/components/shared/text-buffer.test.ts
index fb75179e..b5f2d8c0 100644
--- a/packages/cli/src/ui/components/shared/text-buffer.test.ts
+++ b/packages/cli/src/ui/components/shared/text-buffer.test.ts
@@ -5,6 +5,7 @@
*/
import { describe, it, expect, beforeEach } from 'vitest';
+import stripAnsi from 'strip-ansi';
import { renderHook, act } from '@testing-library/react';
import {
useTextBuffer,
@@ -1278,6 +1279,45 @@ Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots
);
expect(getBufferState(result).text).toBe('Pasted Text');
});
+
+ it('should not strip popular emojis', () => {
+ const { result } = renderHook(() =>
+ useTextBuffer({ viewport, isValidPath: () => false }),
+ );
+ const emojis = '🐍🐳🦀🦄';
+ act(() =>
+ result.current.handleInput({
+ name: '',
+ ctrl: false,
+ meta: false,
+ shift: false,
+ paste: false,
+ sequence: emojis,
+ }),
+ );
+ expect(getBufferState(result).text).toBe(emojis);
+ });
+ });
+
+ describe('stripAnsi', () => {
+ it('should correctly strip ANSI escape codes', () => {
+ const textWithAnsi = '\x1B[31mHello\x1B[0m World';
+ expect(stripAnsi(textWithAnsi)).toBe('Hello World');
+ });
+
+ it('should handle multiple ANSI codes', () => {
+ const textWithMultipleAnsi = '\x1B[1m\x1B[34mBold Blue\x1B[0m Text';
+ expect(stripAnsi(textWithMultipleAnsi)).toBe('Bold Blue Text');
+ });
+
+ it('should not modify text without ANSI codes', () => {
+ const plainText = 'Plain text';
+ expect(stripAnsi(plainText)).toBe('Plain text');
+ });
+
+ it('should handle empty string', () => {
+ expect(stripAnsi('')).toBe('');
+ });
});
});