The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { assert, describe, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { encodePngIco } from "./icon-export.ts"; |
| 4 | |
| 5 | const pngHeader = (width: number, height: number) => { |
| 6 | const contents = Buffer.alloc(24); |
| 7 | Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]).copy(contents); |
| 8 | contents.write("IHDR", 12, "ascii"); |
| 9 | contents.writeUInt32BE(width, 16); |
| 10 | contents.writeUInt32BE(height, 20); |
| 11 | return contents; |
| 12 | }; |
| 13 | |
| 14 | describe("icon export", () => { |
| 15 | it("encodes PNG renditions into an ICO directory", () => { |
| 16 | const small = pngHeader(16, 16); |
| 17 | const large = pngHeader(256, 256); |
| 18 | const ico = encodePngIco([ |
| 19 | { size: 16, contents: small }, |
| 20 | { size: 256, contents: large }, |
| 21 | ]); |
| 22 | |
| 23 | assert.equal(ico.readUInt16LE(2), 1); |
| 24 | assert.equal(ico.readUInt16LE(4), 2); |
| 25 | assert.equal(ico.readUInt8(6), 16); |
| 26 | assert.equal(ico.readUInt8(22), 0); |
| 27 | assert.equal(ico.readUInt32LE(18), 38); |
| 28 | assert.equal(ico.readUInt32LE(34), 38 + small.length); |
| 29 | assert.deepEqual(ico.subarray(38, 38 + small.length), small); |
| 30 | assert.deepEqual(ico.subarray(38 + small.length), large); |
| 31 | }); |
| 32 | }); |