Enhance RuntimeHost unit tests to track and assert pressed keys state
This commit is contained in:
@@ -3979,6 +3979,7 @@ describe("RuntimeHost", () => {
|
|||||||
};
|
};
|
||||||
runtimeScene: unknown;
|
runtimeScene: unknown;
|
||||||
sceneReady: boolean;
|
sceneReady: boolean;
|
||||||
|
pressedKeys: Set<string>;
|
||||||
activeRuntimeTargetReference: {
|
activeRuntimeTargetReference: {
|
||||||
kind: "npc" | "interactable";
|
kind: "npc" | "interactable";
|
||||||
entityId: string;
|
entityId: string;
|
||||||
@@ -4027,6 +4028,7 @@ describe("RuntimeHost", () => {
|
|||||||
kind: "npc",
|
kind: "npc",
|
||||||
entityId: "npc-active"
|
entityId: "npc-active"
|
||||||
};
|
};
|
||||||
|
hostInternals.pressedKeys.add("Escape");
|
||||||
hostInternals.controllerContext.setPlayerControllerTelemetry({
|
hostInternals.controllerContext.setPlayerControllerTelemetry({
|
||||||
pointerLocked: true,
|
pointerLocked: true,
|
||||||
hooks: {
|
hooks: {
|
||||||
@@ -4047,6 +4049,7 @@ describe("RuntimeHost", () => {
|
|||||||
kind: "npc",
|
kind: "npc",
|
||||||
entityId: "npc-active"
|
entityId: "npc-active"
|
||||||
});
|
});
|
||||||
|
expect(hostInternals.pressedKeys.size).toBe(0);
|
||||||
expect(exitPointerLock).not.toHaveBeenCalled();
|
expect(exitPointerLock).not.toHaveBeenCalled();
|
||||||
expect(escapeEvent.preventDefault).not.toHaveBeenCalled();
|
expect(escapeEvent.preventDefault).not.toHaveBeenCalled();
|
||||||
expect(escapeEvent.stopImmediatePropagation).toHaveBeenCalledTimes(1);
|
expect(escapeEvent.stopImmediatePropagation).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user