Skip to content

Commit efc970f

Browse files
authored
Merge pull request #1 from Shopify/louix/main
Add test
2 parents eb38acb + 8a956be commit efc970f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { surface } from "../setup";
2+
3+
describe("Colors", () => {
4+
it("should support int, string, array, and Float32Array", async () => {
5+
const result = await surface.eval((Skia) => {
6+
const areEqualFloat32Arrays = (...arrays: Float32Array[]) => {
7+
// Check if all arrays have the same length
8+
const allSameLength = arrays.every(
9+
(array) => array.length === arrays[0].length
10+
);
11+
if (!allSameLength) {
12+
return false;
13+
}
14+
15+
// Compare elements across all arrays for each index
16+
for (let i = 0; i < arrays[0].length; i++) {
17+
if (!arrays.every((array) => array[i] === arrays[0][i])) {
18+
return false;
19+
}
20+
}
21+
22+
return true;
23+
};
24+
25+
const c1 = Skia.Color("cyan");
26+
const c2 = Skia.Color([0, 1, 1, 1]);
27+
const c3 = Skia.Color(0xff00ffff);
28+
const c4 = Skia.Color(Float32Array.of(0, 1, 1, 1));
29+
30+
const r = areEqualFloat32Arrays(c1, c2, c3, c4);
31+
if (!r) {
32+
console.log({ c1, c2, c3, c4 });
33+
}
34+
return r;
35+
});
36+
expect(result).toBe(true);
37+
});
38+
});

0 commit comments

Comments
 (0)