(actual: string, expected: string, label: string)
| 43 | const ALPHA_TOL = 0.04 // ±0.04 alpha — accommodates curve-fit residuals across themes |
| 44 | |
| 45 | function expectColorClose(actual: string, expected: string, label: string) { |
| 46 | const a = parseRgba(actual) |
| 47 | const e = parseRgba(expected) |
| 48 | if (!a || !e) { |
| 49 | expect(actual, `${label}: unparseable`).toBe(expected) |
| 50 | return |
| 51 | } |
| 52 | for (let i = 0; i < 3; i++) { |
| 53 | const d = Math.abs(a.rgb[i] - e.rgb[i]) |
| 54 | expect(d, `${label}: channel ${i} ${a.rgb[i]} vs ${e.rgb[i]} (got=${actual} want=${expected})`).toBeLessThanOrEqual(HEX_TOL) |
| 55 | } |
| 56 | expect(Math.abs(a.a - e.a), `${label}: alpha ${a.a} vs ${e.a}`).toBeLessThanOrEqual(ALPHA_TOL) |
| 57 | } |
| 58 | |
| 59 | /* ---------- tokens we cover ---------- */ |
| 60 |
no test coverage detected