From 1a00a5a9af62dd335d7914bfcb5b3432cb83ae4c Mon Sep 17 00:00:00 2001 From: "@permadeath.com" Date: Sat, 8 Aug 2026 19:08:40 -0400 Subject: [PATCH] test: stickers embed the mark verbatim; pngSize parsing --- scripts/render-icons.test.mjs | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/render-icons.test.mjs diff --git a/scripts/render-icons.test.mjs b/scripts/render-icons.test.mjs new file mode 100644 index 0000000..c841b0b --- /dev/null +++ b/scripts/render-icons.test.mjs @@ -0,0 +1,36 @@ +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') + }) +}) -- 2.51.2