feat: finish the homepage plugin, move service links and canvas out of core (B19)

This commit is contained in:
LukeGus committed 2026-09-24 15:07:25 -05:00
1 parent 21937a6b02
commit d4ec444558
256 files changed
+27365 -9077

No files matched your search

@@ -0,0 +1,42 @@
import { describe, it, expect } from "vitest";
import {
snapToGrid,
snapToGridFloor,
} from "../../../src/frontend/canvas/snapToGrid.js";
import { GRID_SIZE } from "../../../src/frontend/types.js";
describe("snapToGrid", () => {
it("snaps to nearest grid multiple", () => {
expect(snapToGrid(0)).toBe(0);
expect(snapToGrid(GRID_SIZE)).toBe(GRID_SIZE);
expect(snapToGrid(GRID_SIZE * 2)).toBe(GRID_SIZE * 2);
});
it("rounds to nearest (up when exactly halfway)", () => {
expect(snapToGrid(GRID_SIZE / 2)).toBe(GRID_SIZE);
expect(snapToGrid(GRID_SIZE * 1.5)).toBe(GRID_SIZE * 2);
});
it("rounds down when below halfway", () => {
expect(snapToGrid(GRID_SIZE * 0.4)).toBe(0);
expect(snapToGrid(GRID_SIZE * 1.4)).toBe(GRID_SIZE);
});
it("works with negative values", () => {
expect(snapToGrid(-GRID_SIZE)).toBe(-GRID_SIZE);
expect(snapToGrid(-GRID_SIZE * 0.4)).toBeCloseTo(0);
});
});
describe("snapToGridFloor", () => {
it("always rounds down to floor multiple", () => {
expect(snapToGridFloor(GRID_SIZE - 1)).toBe(0);
expect(snapToGridFloor(GRID_SIZE)).toBe(GRID_SIZE);
expect(snapToGridFloor(GRID_SIZE + 1)).toBe(GRID_SIZE);
expect(snapToGridFloor(GRID_SIZE * 2 - 1)).toBe(GRID_SIZE);
});
it("handles zero", () => {
expect(snapToGridFloor(0)).toBe(0);
});
});