From 8f0c6e04fe8cb7a60a0aae7a72b774b4cfd17c48 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 5 Mar 2026 13:57:17 +0100 Subject: [PATCH] test: add color detection tests to propertyTypes Verify hex colors are detected as 'color' display mode, named colors with color-related keys are detected, and invalid colors are rejected. Co-Authored-By: Claude Opus 4.6 --- src/utils/propertyTypes.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/utils/propertyTypes.test.ts b/src/utils/propertyTypes.test.ts index 5f67d62c..469b5d15 100644 --- a/src/utils/propertyTypes.test.ts +++ b/src/utils/propertyTypes.test.ts @@ -84,6 +84,33 @@ describe('detectPropertyType', () => { it('detects common date format MM/DD/YYYY', () => { expect(detectPropertyType('due', '02/25/2026')).toBe('date') }) + + it('detects hex color values as color', () => { + expect(detectPropertyType('background', '#FFFFFF')).toBe('color') + expect(detectPropertyType('foreground', '#37352F')).toBe('color') + expect(detectPropertyType('primary', '#155DFF')).toBe('color') + expect(detectPropertyType('custom', '#3b82f6')).toBe('color') + }) + + it('detects short hex colors as color', () => { + expect(detectPropertyType('accent', '#fff')).toBe('color') + expect(detectPropertyType('color', '#abc')).toBe('color') + }) + + it('does not detect non-hex named colors without color key', () => { + expect(detectPropertyType('custom_field', 'red')).toBe('text') + expect(detectPropertyType('custom_field', 'blue')).toBe('text') + }) + + it('detects named colors with color-related keys', () => { + expect(detectPropertyType('fill', 'red')).toBe('color') + expect(detectPropertyType('background', 'blue')).toBe('color') + }) + + it('does not detect invalid hex as color', () => { + expect(detectPropertyType('background', '#zzzzzz')).toBe('text') + expect(detectPropertyType('color', 'not-a-color')).toBe('text') + }) }) describe('formatDateValue', () => {