From 23eaeebb901bf92b452ef6760497558775fd0a50 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 11 Apr 2026 03:22:58 +0200 Subject: [PATCH] Add transform-axis-mapping test file --- tests/unit/transform-axis-mapping.test.ts | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/unit/transform-axis-mapping.test.ts diff --git a/tests/unit/transform-axis-mapping.test.ts b/tests/unit/transform-axis-mapping.test.ts new file mode 100644 index 00000000..2a401c20 --- /dev/null +++ b/tests/unit/transform-axis-mapping.test.ts @@ -0,0 +1,53 @@ +import { describe, expect, it } from "vitest"; + +import { resolveDominantLocalAxisForWorldAxis } from "../../src/viewport-three/transform-axis-mapping"; + +describe("transform axis mapping", () => { + it("maps a world axis onto the dominant local axis for rotated targets", () => { + expect( + resolveDominantLocalAxisForWorldAxis( + { + x: 0, + y: 90, + z: 0 + }, + "x" + ) + ).toBe("z"); + + expect( + resolveDominantLocalAxisForWorldAxis( + { + x: 90, + y: 0, + z: 0 + }, + "y" + ) + ).toBe("z"); + }); + + it("keeps the same axis when the target is not rotated", () => { + expect( + resolveDominantLocalAxisForWorldAxis( + { + x: 0, + y: 0, + z: 0 + }, + "x" + ) + ).toBe("x"); + + expect( + resolveDominantLocalAxisForWorldAxis( + { + x: 0, + y: 0, + z: 0 + }, + "z" + ) + ).toBe("z"); + }); +});