mirror of
https://github.com/kevinkickback/Combo-Colors.git
synced 2026-07-22 11:50:29 +00:00
- 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.
30 lines
1.1 KiB
TypeScript
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')
|
|
})
|
|
})
|