Files
snapcad-studio/tests/unit/snapcadPrefabs.test.ts
T

46 lines
1.8 KiB
TypeScript
Raw Normal View History

import { describe, expect, it } from "vitest";
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
describe("SnapCAD Prefabs Catalog", () => {
it("contains high-demand mechanical, maker, everyday, and architectural prefabs", () => {
expect(SNAPCAD_PREFABS.length).toBeGreaterThanOrEqual(14);
const ids = SNAPCAD_PREFABS.map((p) => p.id);
expect(ids).toContain("hex-nut-m8");
expect(ids).toContain("bearing-608zz");
expect(ids).toContain("hex-bolt-m8x35");
expect(ids).toContain("electronics-box");
expect(ids).toContain("arduino-uno-mount");
expect(ids).toContain("nema17-stepper-mount");
expect(ids).toContain("modular-arch-wall");
expect(ids).toContain("spiral-stairs");
expect(ids).toContain("truss-beam");
expect(ids).toContain("domino-run-track");
expect(ids).toContain("modern-terrace-villa");
expect(ids).toContain("retro-arcade-console");
expect(ids).toContain("cable-stayed-bridge");
expect(ids).toContain("iot-smart-hub-case");
});
it("builds valid non-empty shape lists for every prefab", () => {
for (const prefab of SNAPCAD_PREFABS) {
expect(prefab.id).toBeTruthy();
expect(prefab.title).toBeTruthy();
expect(prefab.category).toMatch(/^(mechanical|maker|everyday|architecture)$/);
expect(prefab.categoryLabel).toBeTruthy();
expect(prefab.description).toBeTruthy();
const shapes = prefab.buildShapes();
expect(shapes.length).toBeGreaterThan(0);
for (const shape of shapes) {
expect(shape.id).toBeTruthy();
expect(shape.name).toBeTruthy();
expect(shape.kind).toBeTruthy();
expect(typeof shape.width).toBe("number");
expect(typeof shape.height).toBe("number");
expect(typeof shape.depth).toBe("number");
}
}
});
});