34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { createInitialAppState } from "@editor/initial-state";
|
|
import { documentAddArtboardCommand, documentSetArtboardBoundsCommand } from "./document";
|
|
|
|
describe("document commands", () => {
|
|
test("adds transparent artboard", () => {
|
|
const next = documentAddArtboardCommand.execute(
|
|
{ state: createInitialAppState("Test") },
|
|
{ id: "a1", name: "Artboard 1", bounds: { x: 0, y: 0, w: 320, h: 240 } },
|
|
);
|
|
|
|
expect(next.document.artboards).toEqual([
|
|
{
|
|
id: "a1",
|
|
name: "Artboard 1",
|
|
bounds: { x: 0, y: 0, w: 320, h: 240 },
|
|
backgroundColor: "transparent",
|
|
layers: [],
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("sets artboard bounds", () => {
|
|
const state = documentAddArtboardCommand.execute(
|
|
{ state: createInitialAppState("Test") },
|
|
{ id: "a1", name: "Artboard 1", bounds: { x: 0, y: 0, w: 320, h: 240 } },
|
|
);
|
|
|
|
const next = documentSetArtboardBoundsCommand.execute({ state }, { id: "a1", bounds: { x: 10, y: 20, w: 640, h: 480 } });
|
|
|
|
expect(next.document.artboards[0]?.bounds).toEqual({ x: 10, y: 20, w: 640, h: 480 });
|
|
});
|
|
});
|