diff --git a/src/shared/utils/base/__tests__/string.test.js b/src/shared/utils/base/__tests__/string.test.js index 9546eb03..9fae8126 100644 --- a/src/shared/utils/base/__tests__/string.test.js +++ b/src/shared/utils/base/__tests__/string.test.js @@ -4,6 +4,7 @@ import { escapeTag, escapeTagRecursive, localeIncludes, + replaceBioSymbols, textToHex } from '../string'; @@ -99,4 +100,36 @@ describe('String Utils', () => { expect(changeLogRemoveLinks('![image](url)')).toBe('![image](url)'); }); }); + + describe('replaceBioSymbols', () => { + test('replaces fullwidth symbols with ASCII equivalents', () => { + expect(replaceBioSymbols('@user')).toBe('@user'); + expect(replaceBioSymbols('#tag')).toBe('#tag'); + expect(replaceBioSymbols('1+1=2')).toBe('1+1=2'); + }); + + test('replaces multiple different symbols', () => { + expect(replaceBioSymbols('(hello)')).toBe('(hello)'); + expect(replaceBioSymbols('[test]')).toBe('[test]'); + expect(replaceBioSymbols('{obj}')).toBe('{obj}'); + }); + + test('collapses multiple spaces', () => { + expect(replaceBioSymbols('hello world')).toBe('hello world'); + }); + + test('handles non-string input', () => { + expect(replaceBioSymbols(null)).toBe(''); + expect(replaceBioSymbols(undefined)).toBe(''); + expect(replaceBioSymbols(123)).toBe(''); + }); + + test('handles empty string', () => { + expect(replaceBioSymbols('')).toBe(''); + }); + + test('preserves normal ASCII text', () => { + expect(replaceBioSymbols('hello world')).toBe('hello world'); + }); + }); });