import test from 'node:test'; import assert from 'node:assert/strict'; import {darkTheme,lightTheme} from '../src/core/appearance.ts'; function luminance(color){let hex=color.slice(1);if(hex.length===3)hex=hex.split('').map(c=>c+c).join('');const rgb=[0,2,4].map(i=>parseInt(hex.slice(i,i+2),16)/255).map(c=>c<=.04045?c/12.92:((c+.055)/1.055)**2.4);return rgb[0]*.2126+rgb[1]*.7152+rgb[2]*.0722;} function contrast(a,b){const x=luminance(a),y=luminance(b);return (Math.max(x,y)+.05)/(Math.min(x,y)+.05);} test('normal-sized foregrounds in both themes retain readable contrast',()=>{ for(const theme of [lightTheme,darkTheme])for(const [foreground,background] of [['text','bg'],['text','card'],['muted','card'],['muted','bg'],['onAccent','accent'],['accent','soft']])assert.ok(contrast(theme[foreground],theme[background])>=4.5,`${foreground}/${background} contrast ${contrast(theme[foreground],theme[background])}`); }); test('brand hero retains white-text contrast instead of using the light dark-mode accent',()=>{ for(const theme of [lightTheme,darkTheme])assert.ok(contrast('#ffffff',theme.hero)>=4.5); });