25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { resolveLayerDrawImage, resolveTextLayerDraw } from "./exportArtboardPng";
|
|
|
|
describe("artboard PNG export", () => {
|
|
test("draws only cropped source pixels at their retained document position", () => {
|
|
const draw = resolveLayerDrawImage({
|
|
id: "layer", type: "raster", name: "Layer", visible: true, locked: false, opacity: 1, assetId: "asset",
|
|
sourceRect: { x: 10, y: 5, w: 40, h: 20 },
|
|
transform: { position: { x: 100, y: 50 }, scale: { x: 2, y: 3 }, rotation: 0 },
|
|
}, { w: 200, h: 100 });
|
|
|
|
expect(draw).toEqual({
|
|
source: { x: 10, y: 5, w: 40, h: 20 },
|
|
destination: { x: 120, y: 65, w: 80, h: 60 },
|
|
});
|
|
});
|
|
|
|
test("uses deterministic text data centered for renderer rotation parity", () => {
|
|
const draw = resolveTextLayerDraw({ id: "text", type: "text", name: "Text", visible: true, locked: false, opacity: 1, transform: { position: { x: 10, y: 20 }, scale: { x: 2, y: 3 }, rotation: 1 }, content: "AB", style: { fontFamily: "Arial", fontSize: 10, fontWeight: 400, fontStyle: "normal", color: "#ffffff", alignment: "center", lineHeight: 1.2 } });
|
|
expect(draw.size).toEqual({ w: 10.8, h: 12 });
|
|
expect(draw.center).toEqual({ x: 20.8, y: 38 });
|
|
expect(draw.textX).toBe(0);
|
|
});
|
|
});
|