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

23 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-06-20 10:07:33 +03:00
import { describe, expect, it } from "vitest";
import { projectExportFileName } from "@/lib/exportNames";
describe("project export filenames", () => {
it("uses the project name for each supported export format", () => {
expect(projectExportFileName("Gearbox Prototype", "3mf")).toBe("Gearbox Prototype.3mf");
2026-06-20 10:07:33 +03:00
expect(projectExportFileName("Gearbox Prototype", "stl")).toBe("Gearbox Prototype.stl");
expect(projectExportFileName("Gearbox Prototype", "obj")).toBe("Gearbox Prototype.obj");
expect(projectExportFileName("Gearbox Prototype", "step")).toBe("Gearbox Prototype.step");
expect(projectExportFileName("Gearbox Prototype", "dxf")).toBe("Gearbox Prototype.dxf");
expect(projectExportFileName("Gearbox Prototype", "glb")).toBe("Gearbox Prototype.glb");
expect(projectExportFileName("Gearbox Prototype", "svg")).toBe("Gearbox Prototype.svg");
expect(projectExportFileName("Gearbox Prototype", "skf")).toBe("Gearbox Prototype.skf");
2026-06-20 10:07:33 +03:00
});
it("removes filesystem-reserved characters without discarding the project name", () => {
expect(projectExportFileName(' enclosure: v2 / final? ', "stl")).toBe("enclosure- v2 - final-.stl");
});
it("falls back to a useful name when the project name cannot be used", () => {
expect(projectExportFileName("...", "obj")).toBe("SketchForge design.obj");
});
});