Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 697c4a8

Browse files
committed
test: add testing case for drawLine
1 parent b91cb35 commit 697c4a8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/draw/__tests__/drawLineOnImage.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ test('RGB image', () => {
2020
expect(result).not.toBe(image);
2121
});
2222

23+
test('RGBA image with different alphas', () => {
24+
const image = testUtils.createRgbaImage([
25+
[100, 150, 200, 150, 100, 150, 0, 150],
26+
[100, 200, 5, 150, 3, 200, 0, 150],
27+
[150, 200, 255, 150, 6, 150, 0, 150],
28+
]);
29+
30+
const from = { row: 0, column: 0 };
31+
const to = { row: 1, column: 1 };
32+
const result = image.drawLine(from, to, { strokeColor: [255, 0, 0, 50] });
33+
expect(result).toMatchImageData([
34+
[145, 106, 141, 170, 100, 150, 0, 150],
35+
[100, 200, 5, 150, 76, 141, 0, 170],
36+
[150, 200, 255, 150, 6, 150, 0, 150],
37+
]);
38+
expect(result).not.toBe(image);
39+
});
40+
2341
test('out parameter set to self', () => {
2442
const image = testUtils.createRgbImage([
2543
[100, 150, 200, 100, 150, 0],

0 commit comments

Comments
 (0)