add unit test

This commit is contained in:
pa
2026-02-12 15:59:23 +09:00
parent 4039698c71
commit 6c6f2211cd

View File

@@ -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('')).toBe('+=');
});
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');
});
});
});