Skip to content

Commit 1aea873

Browse files
committed
a couple TransformMatrix unit tests
1 parent 04fe818 commit 1aea873

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import TransformMatrix from "./TransformMatrix";
2+
3+
test("TransformMatrix empty constructor", () => {
4+
const mat = new TransformMatrix();
5+
expect(mat._matrix).toBeInstanceOf(DOMMatrix);
6+
// prettier-ignore
7+
expect([
8+
mat.a, mat.c, mat.e,
9+
mat.b, mat.d, mat.f
10+
]).toEqual([
11+
1, 0, 0,
12+
0, 1, 0,
13+
]);
14+
});
15+
16+
test("TransformMatrix constructor with args", () => {
17+
const mat = new TransformMatrix(2, 3, 4, 5, 6, 7);
18+
expect(mat._matrix).toBeInstanceOf(DOMMatrix);
19+
// prettier-ignore
20+
expect([
21+
mat.a, mat.c, mat.e,
22+
mat.b, mat.d, mat.f
23+
]).toEqual([
24+
2, 4, 6,
25+
3, 5, 7,
26+
]);
27+
});
28+
29+
test("TransformMatrix scale", () => {
30+
const mat = new TransformMatrix();
31+
const mat2 = mat.scale(2, 3, 0.3, 0.4);
32+
// prettier-ignore
33+
expect([
34+
mat2.a, mat2.c, mat2.e,
35+
mat2.b, mat2.d, mat2.f
36+
]).toMatchObject([
37+
2, 0, -0.30000001192092896,
38+
0, 3, -0.8000000715255737,
39+
]);
40+
});

tsconfig.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
"./ts-webpack.ts"
88
],
99
"include": ["./packages/**/*.ts", "./packages/**/*.tsx"],
10-
"exclude": [
11-
"./packages/**/*.test.ts",
12-
"./packages/scripts/**/*",
13-
"./packages/create/template/**/*"
14-
],
10+
"exclude": ["./packages/scripts/**/*", "./packages/create/template/**/*"],
1511

1612
"compilerOptions": {
1713
"lib": ["es2019", "dom"],

0 commit comments

Comments
 (0)