Add tests for world settings command and helpers

This commit is contained in:
2026-03-31 05:13:53 +02:00
parent 2d90b6b31e
commit 4ba4a9adf0
2 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import { createEditorStore } from "../../src/app/editor-store";
import { createSetWorldSettingsCommand } from "../../src/commands/set-world-settings-command";
import { createEmptySceneDocument } from "../../src/document/scene-document";
import { cloneWorldSettings } from "../../src/document/world-settings";
describe("createSetWorldSettingsCommand", () => {
it("updates authored world settings and restores them through undo", () => {
const store = createEditorStore();
const originalWorld = cloneWorldSettings(store.getState().document.world);
const nextWorld = cloneWorldSettings(originalWorld);
nextWorld.background = {
mode: "verticalGradient",
topColorHex: "#6e8db4",
bottomColorHex: "#18212b"
};
nextWorld.ambientLight.intensity = 0.45;
store.executeCommand(
createSetWorldSettingsCommand({
label: "Set world lighting",
world: nextWorld
})
);
expect(store.getState().document.world).toEqual(nextWorld);
expect(store.undo()).toBe(true);
expect(store.getState().document.world).toEqual(createEmptySceneDocument().world);
});
});