|
| 1 | +import { describe, it, expect } from 'vitest' |
| 2 | +import { parseSuggestionIntent } from '../../app/composables/npm/search-utils' |
| 3 | + |
| 4 | +describe('Search case normalization', () => { |
| 5 | + describe('parseSuggestionIntent', () => { |
| 6 | + it('should preserve case in name extraction for org queries', () => { |
| 7 | + const result = parseSuggestionIntent('@AnGuLAR') |
| 8 | + expect(result.intent).toBe('org') |
| 9 | + expect(result.name).toBe('AnGuLAR') |
| 10 | + }) |
| 11 | + |
| 12 | + it('should preserve case in name extraction for user queries', () => { |
| 13 | + const result = parseSuggestionIntent('~daNIEL') |
| 14 | + expect(result.intent).toBe('user') |
| 15 | + expect(result.name).toBe('daNIEL') |
| 16 | + }) |
| 17 | + |
| 18 | + it('should preserve case in name extraction for both queries', () => { |
| 19 | + const result = parseSuggestionIntent('AnGuLAR') |
| 20 | + expect(result.intent).toBe('both') |
| 21 | + expect(result.name).toBe('AnGuLAR') |
| 22 | + }) |
| 23 | + |
| 24 | + it('should handle lowercase org names', () => { |
| 25 | + const result = parseSuggestionIntent('@angular') |
| 26 | + expect(result.intent).toBe('org') |
| 27 | + expect(result.name).toBe('angular') |
| 28 | + }) |
| 29 | + |
| 30 | + it('should handle lowercase user names', () => { |
| 31 | + const result = parseSuggestionIntent('~daniel') |
| 32 | + expect(result.intent).toBe('user') |
| 33 | + expect(result.name).toBe('daniel') |
| 34 | + }) |
| 35 | + }) |
| 36 | + |
| 37 | + describe('Case normalization expectations', () => { |
| 38 | + it('should expect suggestions to normalize names to lowercase', () => { |
| 39 | + const mixedCaseOrg = parseSuggestionIntent('@AnGuLAR') |
| 40 | + expect(mixedCaseOrg.name).toBe('AnGuLAR') |
| 41 | + |
| 42 | + const expectedNormalized = mixedCaseOrg.name.toLowerCase() |
| 43 | + expect(expectedNormalized).toBe('angular') |
| 44 | + }) |
| 45 | + }) |
| 46 | +}) |
0 commit comments