Refactor ViewportPanel to use EditorSimulationController and add unit tests for player interact input bindings
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createPlayerStartInputBindings } from "../../src/entities/entity-instances";
|
||||
import { resolvePlayerStartPauseInput } from "../../src/runtime-three/player-input-bindings";
|
||||
import {
|
||||
resolvePlayerStartInteractInput,
|
||||
resolvePlayerStartPauseInput
|
||||
} from "../../src/runtime-three/player-input-bindings";
|
||||
|
||||
function createMockGamepad(pressedButtons: number[] = []): Gamepad {
|
||||
return {
|
||||
@@ -51,3 +54,34 @@ describe("player-input-bindings pause input", () => {
|
||||
).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("player-input-bindings interact input", () => {
|
||||
it("resolves authored keyboard interact bindings", () => {
|
||||
const bindings = createPlayerStartInputBindings({
|
||||
keyboard: {
|
||||
interact: "KeyE"
|
||||
}
|
||||
});
|
||||
|
||||
expect(resolvePlayerStartInteractInput(new Set(["MouseLeft"]), bindings, [])).toBe(
|
||||
0
|
||||
);
|
||||
expect(resolvePlayerStartInteractInput(new Set(["KeyE"]), bindings, [])).toBe(
|
||||
1
|
||||
);
|
||||
});
|
||||
|
||||
it("resolves the authored gamepad interact binding from the standard west button", () => {
|
||||
const bindings = createPlayerStartInputBindings({
|
||||
gamepad: {
|
||||
interact: "buttonWest"
|
||||
}
|
||||
});
|
||||
|
||||
expect(
|
||||
resolvePlayerStartInteractInput(new Set<string>(), bindings, [
|
||||
createMockGamepad([2])
|
||||
])
|
||||
).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user