Files

15 lines
1.0 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { THEME, CONTRAST_PAIRS, contrast } from '../src/design-tokens.js';
import { ICON_ATLAS, ICON_SIZE, ICONS, PANELS, PANEL_SIZE } from '../src/ui-skin.js';
test('semantic text and control color pairs meet their declared contrast requirements',()=>{
for(const [label,fg,bg,min] of CONTRAST_PAIRS)assert.ok(contrast(THEME[fg],THEME[bg])>=min,label);
});
test('accepted generated artwork is referenced and all optical-center crop frames fit the atlas',()=>{
assert.equal(ICON_ATLAS,'assets/ui-icons-generated.png');
const png=readFileSync(new URL('../'+ICON_ATLAS,import.meta.url));assert.equal(png.readUInt32BE(16),ICON_SIZE.w);assert.equal(png.readUInt32BE(20),ICON_SIZE.h);
for(const f of Object.values(ICONS)){assert.equal(f.w,f.h);assert.ok(f.x>=0&&f.y>=0&&f.x+f.w<=ICON_SIZE.w&&f.y+f.h<=ICON_SIZE.h);}
for(const f of Object.values(PANELS))assert.ok(f.x+f.w<=PANEL_SIZE.w&&f.y+f.h<=PANEL_SIZE.h);
});