|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import { resolveKnownClientKey } from '../../../apps/desktop/src/lib/clientIcons'; |
| 3 | + |
| 4 | +describe('resolveKnownClientKey', () => { |
| 5 | + describe('exact matches', () => { |
| 6 | + it('should resolve "cursor" to cursor', () => { |
| 7 | + expect(resolveKnownClientKey('cursor')).toBe('cursor'); |
| 8 | + }); |
| 9 | + |
| 10 | + it('should resolve "Cursor" (case-insensitive) to cursor', () => { |
| 11 | + expect(resolveKnownClientKey('Cursor')).toBe('cursor'); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should resolve "claude" to claude', () => { |
| 15 | + expect(resolveKnownClientKey('claude')).toBe('claude'); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should resolve "Claude Desktop" to claude', () => { |
| 19 | + expect(resolveKnownClientKey('Claude Desktop')).toBe('claude'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should resolve "vs code" to vscode', () => { |
| 23 | + expect(resolveKnownClientKey('vs code')).toBe('vscode'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should resolve "vscode" to vscode', () => { |
| 27 | + expect(resolveKnownClientKey('vscode')).toBe('vscode'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should resolve "Visual Studio Code" to vscode', () => { |
| 31 | + expect(resolveKnownClientKey('Visual Studio Code')).toBe('vscode'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should resolve "windsurf" to windsurf', () => { |
| 35 | + expect(resolveKnownClientKey('windsurf')).toBe('windsurf'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should resolve "codeium" to windsurf', () => { |
| 39 | + expect(resolveKnownClientKey('codeium')).toBe('windsurf'); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + describe('prefix matches with parenthesised suffix', () => { |
| 44 | + it('should resolve "Claude Code (mcpmux)" to claude', () => { |
| 45 | + expect(resolveKnownClientKey('Claude Code (mcpmux)')).toBe('claude'); |
| 46 | + }); |
| 47 | + |
| 48 | + it('should resolve "Claude Desktop (some-server)" to claude', () => { |
| 49 | + expect(resolveKnownClientKey('Claude Desktop (some-server)')).toBe('claude'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should resolve "Cursor (my-project)" to cursor', () => { |
| 53 | + expect(resolveKnownClientKey('Cursor (my-project)')).toBe('cursor'); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should resolve "VS Code (workspace)" to vscode', () => { |
| 57 | + expect(resolveKnownClientKey('VS Code (workspace)')).toBe('vscode'); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should resolve "Windsurf (test)" to windsurf', () => { |
| 61 | + expect(resolveKnownClientKey('Windsurf (test)')).toBe('windsurf'); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + describe('prefix matches with space-separated suffix', () => { |
| 66 | + it('should resolve "Claude Code v2" to claude', () => { |
| 67 | + expect(resolveKnownClientKey('Claude Code v2')).toBe('claude'); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should resolve "Cursor beta" to cursor', () => { |
| 71 | + expect(resolveKnownClientKey('Cursor beta')).toBe('cursor'); |
| 72 | + }); |
| 73 | + }); |
| 74 | + |
| 75 | + describe('non-matching names', () => { |
| 76 | + it('should return null for unknown client names', () => { |
| 77 | + expect(resolveKnownClientKey('unknown-client')).toBeNull(); |
| 78 | + }); |
| 79 | + |
| 80 | + it('should return null for empty string', () => { |
| 81 | + expect(resolveKnownClientKey('')).toBeNull(); |
| 82 | + }); |
| 83 | + |
| 84 | + it('should not match partial names without word boundary', () => { |
| 85 | + // "claudeXYZ" should NOT match "claude" — no word boundary |
| 86 | + expect(resolveKnownClientKey('claudeXYZ')).toBeNull(); |
| 87 | + }); |
| 88 | + |
| 89 | + it('should not match "cursorify" (no word boundary)', () => { |
| 90 | + expect(resolveKnownClientKey('cursorify')).toBeNull(); |
| 91 | + }); |
| 92 | + }); |
| 93 | + |
| 94 | + describe('whitespace handling', () => { |
| 95 | + it('should trim leading/trailing whitespace', () => { |
| 96 | + expect(resolveKnownClientKey(' Cursor ')).toBe('cursor'); |
| 97 | + }); |
| 98 | + |
| 99 | + it('should handle whitespace with suffix', () => { |
| 100 | + expect(resolveKnownClientKey(' Claude Code (mcpmux) ')).toBe('claude'); |
| 101 | + }); |
| 102 | + }); |
| 103 | +}); |
0 commit comments