diff --git a/server/src/compare.test.js b/server/src/compare.test.js index a793fb1..c1e60f6 100644 --- a/server/src/compare.test.js +++ b/server/src/compare.test.js @@ -1,5 +1,6 @@ import fs from "fs/promises"; import { compare } from "./compare.js"; +import { PNG } from "pngjs"; describe("compare", () => { it("returns the number of pixels that differ", async () => { @@ -14,4 +15,20 @@ describe("compare", () => { expect(result.actual).toStrictEqual(actual); expect(result.diff).toStrictEqual(expectedDiff); }); + + it("enlarges images to be able to create diffs", async () => { + const expected = emptyPNG(1920, 1024); + const actual = emptyPNG(2000, 800); + + const result = await compare(expected, actual); + + const diff = PNG.sync.read(result.diff); + expect(diff.width).toStrictEqual(2000); + expect(diff.height).toStrictEqual(1024); + }); }); + +function emptyPNG(width, height) { + const png = new PNG({ width, height }); + return PNG.sync.write(png); +}