From 67d591f4131f5eb258edc81c92e5dbf76c215080 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Mon, 6 Jul 2026 20:35:35 +0200 Subject: [PATCH] Implement unit tests for the `getRotationMatrix` core utility function This function is mostly covered indirectly by higher-level tests, but unlike the other core utility functions it lacked dedicated unit tests. This commit implements unit tests for it that also cover the previously uncovered exception case, which brings coverage of the function to 100% and ever so slighly increases coverage of the overarching file. --- test/unit/core_utils_spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit/core_utils_spec.js b/test/unit/core_utils_spec.js index f8fb1a009..bfb5a98c3 100644 --- a/test/unit/core_utils_spec.js +++ b/test/unit/core_utils_spec.js @@ -21,6 +21,7 @@ import { escapeString, getInheritableProperty, getModificationDate, + getRotationMatrix, getSizeInBytes, isWhiteSpace, numberToString, @@ -566,6 +567,20 @@ describe("core_utils", function () { }); }); + describe("getRotationMatrix", function () { + it("should get a rotation matrix for valid rotation values", function () { + expect(getRotationMatrix(90, 10, 20)).toEqual([0, 1, -1, 0, 10, 0]); + expect(getRotationMatrix(180, 10, 20)).toEqual([-1, 0, 0, -1, 10, 20]); + expect(getRotationMatrix(270, 10, 20)).toEqual([0, -1, 1, 0, 0, 20]); + }); + + it("throws an exception for invalid rotation values", function () { + expect(() => getRotationMatrix(42, 10, 20)).toThrow( + new Error("Invalid rotation") + ); + }); + }); + describe("getSizeInBytes", function () { it("should get the size in bytes to use to represent a positive integer", function () { expect(getSizeInBytes(0)).toEqual(0);