kevinkickback_Combo-Colors/tests/input-validation.test.ts
kevinkickback f5b8958691 feat: enhance profile management and validation
- Introduced functions for cloning profiles and creating default settings.
- Added validation for profile IDs and input names, ensuring they meet specific criteria.
- Implemented color validation for CSS colors to ensure safe usage.
- Enhanced settings merging logic to prevent mutation of default settings.
- Added new classes for managing styles dynamically based on profiles.
- Implemented a mode toggle for rendering notations as images or text.
- Created a notation observer to handle dynamic updates in the UI.
- Added comprehensive tests for input validation, profile validation, and mode toggling functionality.
- Removed deprecated button styling from CSS.
2026-05-13 17:28:07 -07:00

30 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { validateAndNormalizeInputs } from '../src/input-validation'
describe('validateAndNormalizeInputs', () => {
it('normalizes names and descriptions via trim', () => {
const result = validateAndNormalizeInputs([
{ name: ' LP ', description: ' Light punch ', color: '#ffffff' },
])
expect(result.valid).toBe(true)
expect(result.inputs).toEqual([{ name: 'LP', description: 'Light punch', color: '#ffffff' }])
})
it('rejects invalid characters', () => {
const result = validateAndNormalizeInputs([{ name: 'LP+', description: '', color: '#ffffff' }])
expect(result.valid).toBe(false)
expect(result.message).toContain('letters, numbers, underscores, and hyphens')
})
it('rejects duplicates case-insensitively', () => {
const result = validateAndNormalizeInputs([
{ name: 'lp', description: '', color: '#ffffff' },
{ name: 'LP', description: '', color: '#000000' },
])
expect(result.valid).toBe(false)
expect(result.message).toBe('Duplicate input name: LP')
})
})