import { readFileSync } from 'node:fs' import { join } from 'node:path' import { describe, expect, it } from 'vitest' import { pngSize } from './render-icons.mjs' const brand = join(import.meta.dirname, '..', 'brand') describe('sticker variants embed the mark verbatim', () => { // Both stickers claim to hold mark.svg's elements unchanged, only wrapped // in a scale/translate. If someone tweaks a rect or the squiggle in one // place but not the others, the logo forks. const markLines = readFileSync(join(brand, 'mark.svg'), 'utf8') .split('\n') .map((l) => l.trim()) .filter((l) => l.startsWith(' { const svg = readFileSync(join(brand, file), 'utf8') expect(markLines.length).toBeGreaterThan(0) for (const line of markLines) { expect(svg).toContain(line) } }) }) describe('pngSize', () => { it('reads IHDR dimensions', () => { const png = readFileSync(join(brand, 'icon480-round.png')) expect(pngSize(png)).toEqual({ width: 480, height: 480 }) }) it('rejects non-PNG bytes', () => { expect(() => pngSize(new Uint8Array([1, 2, 3]))).toThrow('not a PNG') }) })