diff --git a/tests/domain/scene-document-validation.test.ts b/tests/domain/scene-document-validation.test.ts index 86c8c3d2..3535db16 100644 --- a/tests/domain/scene-document-validation.test.ts +++ b/tests/domain/scene-document-validation.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { createBoxBrush } from "../../src/document/brushes"; +import { createScenePath } from "../../src/document/paths"; import { createEmptySceneDocument } from "../../src/document/scene-document"; import { validateSceneDocument } from "../../src/document/scene-document-validation"; import { @@ -847,4 +848,60 @@ describe("validateSceneDocument", () => { ]) ); }); + + it("detects invalid authored path foundations", () => { + const invalidPath = createScenePath({ + id: "path-invalid", + points: [ + { + id: "path-point-a", + position: { + x: 0, + y: 0, + z: 0 + } + }, + { + id: "path-point-b", + position: { + x: 1, + y: 0, + z: 0 + } + } + ] + }); + + invalidPath.name = " "; + invalidPath.points = [ + { + id: "path-point-a", + position: { + x: 0, + y: 0, + z: 0 + } + } + ] as typeof invalidPath.points; + + const validation = validateSceneDocument({ + ...createEmptySceneDocument(), + paths: { + [invalidPath.id]: invalidPath + } + }); + + expect(validation.errors).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + code: "invalid-path-name", + path: "paths.path-invalid.name" + }), + expect.objectContaining({ + code: "invalid-path-point-count", + path: "paths.path-invalid.points" + }) + ]) + ); + }); });