Update empty scene document test and add validation tests for invalid world settings
This commit is contained in:
@@ -9,6 +9,25 @@ describe("createEmptySceneDocument", () => {
|
|||||||
|
|
||||||
expect(document.version).toBe(SCENE_DOCUMENT_VERSION);
|
expect(document.version).toBe(SCENE_DOCUMENT_VERSION);
|
||||||
expect(document.name).toBe("Untitled Scene");
|
expect(document.name).toBe("Untitled Scene");
|
||||||
|
expect(document.world).toEqual({
|
||||||
|
background: {
|
||||||
|
mode: "solid",
|
||||||
|
colorHex: "#2f3947"
|
||||||
|
},
|
||||||
|
ambientLight: {
|
||||||
|
colorHex: "#f7f1e8",
|
||||||
|
intensity: 1
|
||||||
|
},
|
||||||
|
sunLight: {
|
||||||
|
colorHex: "#fff1d5",
|
||||||
|
intensity: 1.75,
|
||||||
|
direction: {
|
||||||
|
x: -0.6,
|
||||||
|
y: 1,
|
||||||
|
z: 0.35
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
expect(document.brushes).toEqual({});
|
expect(document.brushes).toEqual({});
|
||||||
expect(document.entities).toEqual({});
|
expect(document.entities).toEqual({});
|
||||||
expect(document.modelInstances).toEqual({});
|
expect(document.modelInstances).toEqual({});
|
||||||
|
|||||||
@@ -116,4 +116,38 @@ describe("validateSceneDocument", () => {
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("detects invalid world lighting and background settings", () => {
|
||||||
|
const document = createEmptySceneDocument();
|
||||||
|
document.world.background = {
|
||||||
|
mode: "verticalGradient",
|
||||||
|
topColorHex: "sky-blue",
|
||||||
|
bottomColorHex: "#18212b"
|
||||||
|
};
|
||||||
|
document.world.ambientLight.intensity = -0.25;
|
||||||
|
document.world.sunLight.direction = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const validation = validateSceneDocument(document);
|
||||||
|
|
||||||
|
expect(validation.errors).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
code: "invalid-world-background-top-color",
|
||||||
|
path: "world.background.topColorHex"
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
code: "invalid-world-ambient-intensity",
|
||||||
|
path: "world.ambientLight.intensity"
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
code: "invalid-world-sun-direction",
|
||||||
|
path: "world.sunLight.direction"
|
||||||
|
})
|
||||||
|
])
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user