Add emitCameraStateChange function and import ViewportPanelCameraState
This commit is contained in:
@@ -10,6 +10,7 @@ import type { ActiveTransformSession, TransformSessionState } from "../../src/co
|
||||
import { createBoxBrush } from "../../src/document/brushes";
|
||||
import { createEmptySceneDocument } from "../../src/document/scene-document";
|
||||
import { createPlayerStartEntity } from "../../src/entities/entity-instances";
|
||||
import type { ViewportPanelCameraState } from "../../src/viewport-three/viewport-layout";
|
||||
|
||||
const { MockViewportHost, viewportHostInstances } = vi.hoisted(() => {
|
||||
const viewportHostInstances: Array<{
|
||||
@@ -249,6 +250,18 @@ function commitTransform(viewportHost: ReturnType<typeof getTopLeftViewportHost>
|
||||
});
|
||||
}
|
||||
|
||||
function emitCameraStateChange(viewportHost: ReturnType<typeof getTopLeftViewportHost>, cameraState: ViewportPanelCameraState) {
|
||||
const handler = viewportHost.setCameraStateChangeHandler.mock.calls.at(-1)?.[0] as ((cameraState: ViewportPanelCameraState) => void) | undefined;
|
||||
|
||||
if (handler === undefined) {
|
||||
throw new Error("Camera state change handler was not registered.");
|
||||
}
|
||||
|
||||
act(() => {
|
||||
handler(cameraState);
|
||||
});
|
||||
}
|
||||
|
||||
describe("transform foundation integration", () => {
|
||||
beforeEach(() => {
|
||||
viewportHostInstances.length = 0;
|
||||
|
||||
Reference in New Issue
Block a user