|
| 1 | +import { onValidateHandles } from '../useProfileForm'; |
| 2 | + |
| 3 | +describe('onValidateHandles', () => { |
| 4 | + it('should accept accented characters in social handles', () => { |
| 5 | + const before = {}; |
| 6 | + const after = { |
| 7 | + twitter: 'ítalo-oliveira-800923162', |
| 8 | + github: 'José', |
| 9 | + linkedin: 'François', |
| 10 | + username: 'Müller', |
| 11 | + }; |
| 12 | + |
| 13 | + const result = onValidateHandles(before, after); |
| 14 | + |
| 15 | + expect(result).toEqual({}); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should accept accented characters in username', () => { |
| 19 | + const before = { username: 'oldname' }; |
| 20 | + const after = { username: 'José_González' }; |
| 21 | + |
| 22 | + const result = onValidateHandles(before, after); |
| 23 | + |
| 24 | + expect(result).toEqual({}); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should accept Unicode characters from various languages', () => { |
| 28 | + const before = {}; |
| 29 | + const after = { |
| 30 | + username: 'Борис', // Cyrillic |
| 31 | + twitter: '北京', // Chinese |
| 32 | + github: 'جوزيف', // Arabic |
| 33 | + }; |
| 34 | + |
| 35 | + const result = onValidateHandles(before, after); |
| 36 | + |
| 37 | + expect(result).toEqual({}); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should accept mixed Unicode and ASCII characters', () => { |
| 41 | + const before = {}; |
| 42 | + const after = { |
| 43 | + twitter: '@José-González_123', |
| 44 | + github: 'François-dev', |
| 45 | + username: 'Müller_Corp', |
| 46 | + }; |
| 47 | + |
| 48 | + const result = onValidateHandles(before, after); |
| 49 | + |
| 50 | + expect(result).toEqual({}); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should still accept regular ASCII usernames', () => { |
| 54 | + const before = {}; |
| 55 | + const after = { |
| 56 | + username: 'john_doe', |
| 57 | + twitter: '@johndoe', |
| 58 | + github: 'johndoe-dev', |
| 59 | + }; |
| 60 | + |
| 61 | + const result = onValidateHandles(before, after); |
| 62 | + |
| 63 | + expect(result).toEqual({}); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should reject usernames that are too short', () => { |
| 67 | + const before = { username: 'oldname' }; |
| 68 | + const after = { username: 'í' }; // Single character |
| 69 | + |
| 70 | + const result = onValidateHandles(before, after); |
| 71 | + |
| 72 | + expect(result.username).toBeDefined(); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should reject empty usernames', () => { |
| 76 | + const before = { username: 'oldname' }; |
| 77 | + const after = { username: '' }; |
| 78 | + |
| 79 | + const result = onValidateHandles(before, after); |
| 80 | + |
| 81 | + expect(result.username).toBeDefined(); |
| 82 | + }); |
| 83 | +}); |
0 commit comments