Skip to content

Commit 2dc955a

Browse files
committed
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.
1 parent 6689097 commit 2dc955a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/unit/core_utils_spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
escapeString,
2222
getInheritableProperty,
2323
getModificationDate,
24+
getRotationMatrix,
2425
getSizeInBytes,
2526
isWhiteSpace,
2627
numberToString,
@@ -566,6 +567,20 @@ describe("core_utils", function () {
566567
});
567568
});
568569

570+
fdescribe("getRotationMatrix", function () {
571+
it("should get a rotation matrix for valid rotation values", function () {
572+
expect(getRotationMatrix(90, 10, 20)).toEqual([0, 1, -1, 0, 10, 0]);
573+
expect(getRotationMatrix(180, 10, 20)).toEqual([-1, 0, 0, -1, 10, 20]);
574+
expect(getRotationMatrix(270, 10, 20)).toEqual([0, -1, 1, 0, 0, 20]);
575+
});
576+
577+
it("throws an exception for invalid rotation values", function () {
578+
expect(() => getRotationMatrix(42, 10, 20)).toThrow(
579+
new Error("Invalid rotation")
580+
);
581+
});
582+
});
583+
569584
describe("getSizeInBytes", function () {
570585
it("should get the size in bytes to use to represent a positive integer", function () {
571586
expect(getSizeInBytes(0)).toEqual(0);

0 commit comments

Comments
 (0)