Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto
Something went wrong. Try again.
995 B · 27 lines
TypeScript
12345678910111213141516171819202122232425262728// 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 declarationsimport { 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('<svg xmlns="..."/>'))).toThrow('not a PNG') expect(() => pngSize(new Uint8Array(0))).toThrow('not a PNG') })})