// The render script's only pure logic: the IHDR sanity check that catches // Chrome's occasional blank- or partial-render misfires. import { describe, expect, it } from 'vitest' // @ts-expect-error plain-node script, no type declarations import { pngSize } from '../../scripts/render-icons.mjs' function fakePng(width: number, height: number): Uint8Array { const bytes = new Uint8Array(24) bytes.set([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]) const dv = new DataView(bytes.buffer) dv.setUint32(16, width) dv.setUint32(20, height) return bytes } describe('pngSize', () => { it('reads IHDR dimensions', () => { expect(pngSize(fakePng(128, 128))).toEqual({ width: 128, height: 128 }) expect(pngSize(fakePng(16, 32))).toEqual({ width: 16, height: 32 }) }) it('rejects non-PNG bytes', () => { expect(() => pngSize(new TextEncoder().encode(''))).toThrow('not a PNG') expect(() => pngSize(new Uint8Array(0))).toThrow('not a PNG') }) })