Skip to content

Commit 02b81dd

Browse files
authored
Use dummy test image
1 parent 64a0510 commit 02b81dd

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

tests/utils/utils.test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,27 @@ describe("Utilities", () => {
6262
});
6363

6464
describe("Image utilities", () => {
65+
const [width, height, channels] = [2, 2, 3];
66+
const data = Uint8Array.from({ length: width * height * channels }, (_, i) => i % 5);
67+
const image = new RawImage(data, width, height, channels);
68+
6569
it("Can split image into separate channels", async () => {
66-
const url = './examples/demo-site/public/images/cats.jpg';
67-
const image = await RawImage.fromURL(url);
68-
// Rather than test the entire image, we'll just test the first 3 pixels;
69-
// ensuring that these match.
70-
const image_data = image.toChannels().map(c => c.slice(0, 3));
70+
const image_data = image.split()
7171

7272
const target = [
73-
new Uint8Array([140, 144, 145]), // Reds
74-
new Uint8Array([25, 25, 25]), // Greens
75-
new Uint8Array([56, 67, 73]), // Blues
73+
new Uint8Array([0, 3, 1, 4]), // Reds
74+
new Uint8Array([1, 4, 2, 0]), // Greens
75+
new Uint8Array([2, 0, 3, 1]), // Blues
7676
];
7777

78-
compare (image_data, target);
78+
compare(image_data, target);
7979
});
8080

8181
it("Can splits channels for grayscale", async () => {
82-
const url = './examples/demo-site/public/images/cats.jpg';
83-
const image = (await RawImage.fromURL(url)).grayscale();
84-
85-
const image_data = image.toChannels().map(c => c.slice(0, 3));
86-
const target = [new Uint8Array([63, 65, 66])];
82+
const image_data = image.grayscale().split();
83+
const target = [new Uint8Array([1, 3, 2, 1])];
8784

88-
compare (image_data, target);
85+
compare(image_data, target);
8986
});
9087
});
9188
});

0 commit comments

Comments
 (0)