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

Commit 7fe372f

Browse files
committed
test: update tests
1 parent ede94d3 commit 7fe372f

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

src/draw/__tests__/drawLineOnImage.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ test('different origin, line out of image', () => {
315315
origin: { column: 0, row: 0 },
316316
strokeColor: [1],
317317
});
318+
318319
expect(result).toMatchImageData([
319320
[1, 0, 0, 0],
320321
[0, 1, 0, 0],

src/utils/__tests__/setBlendedPixel.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ test('GREYA image, default options', () => {
1414

1515
test('GREYA images: transparent source, opaque target', () => {
1616
const image = testUtils.createGreyaImage([[50, 255]]);
17-
setBlendedPixel(image, 0, 0, { color: [100, 0] });
17+
setBlendedPixel(image, 0, 0, [100, 0]);
1818
expect(image).toMatchImageData([[50, 255]]);
1919
});
2020

2121
test('GREYA images: opaque source, transparent target', () => {
2222
const image = testUtils.createGreyaImage([[50, 0]]);
23-
setBlendedPixel(image, 0, 0, { color: [100, 255] });
23+
setBlendedPixel(image, 0, 0, [100, 255]);
2424
expect(image).toMatchImageData([[100, 255]]);
2525
});
2626

2727
test('GREYA image: alpha different from 255', () => {
2828
const image = testUtils.createGreyaImage([[50, 64]]);
29-
setBlendedPixel(image, 0, 0, { color: [100, 128] });
29+
setBlendedPixel(image, 0, 0, [100, 128]);
3030
const alpha = 128 + 64 * (1 - 128 / 255);
3131
const component = (100 * 128 + 50 * 64 * (1 - 128 / 255)) / alpha;
3232
expect(image).toMatchImageData([[component, alpha]]);
@@ -38,7 +38,7 @@ test('asymetrical test', () => {
3838
[20, 30, 5, 6, 7, 8],
3939
[1, 2, 3, 4, 5, 6],
4040
]);
41-
setBlendedPixel(image, 2, 0, { color: [0, 125] });
41+
setBlendedPixel(image, 2, 0, [0, 125]);
4242
expect(image).toMatchImageData([
4343
[50, 255, 1, 2, 0, 127],
4444
[20, 30, 5, 6, 7, 8],
@@ -60,7 +60,7 @@ test('2x2 mask, color is 1', () => {
6060
[1, 0],
6161
[0, 0],
6262
]);
63-
setBlendedPixel(mask, 1, 0, { color: [1] });
63+
setBlendedPixel(mask, 1, 0, [1]);
6464

6565
expect(mask).toMatchMaskData([
6666
[1, 1],

src/utils/__tests__/setBlendedVisiblePixel.test.ts

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,25 @@ test('GREYA image, default options', () => {
1313
});
1414

1515
test('GREYA image: set pixel out of bounds', () => {
16-
const image = testUtils.createGreyaImage([
17-
[50, 255, 1, 2, 3, 4],
18-
[20, 30, 5, 6, 7, 8],
19-
[1, 2, 3, 4, 5, 6],
20-
]);
21-
setBlendedVisiblePixel(image, 0, 5, { color: [40, 40] });
22-
expect(image).toMatchImageData([
16+
const data = [
2317
[50, 255, 1, 2, 3, 4],
2418
[20, 30, 5, 6, 7, 8],
2519
[1, 2, 3, 4, 5, 6],
26-
]);
20+
];
21+
const image = testUtils.createGreyaImage(data);
22+
setBlendedVisiblePixel(image, 0, 5, [40, 40]);
23+
expect(image).toMatchImageData(data);
2724
});
2825

2926
test('RGBA image: set pixel out of bounds', () => {
30-
const image = testUtils.createGreyaImage([
27+
const data = [
3128
[50, 255, 1, 200, 2, 3, 4, 200],
3229
[20, 30, 5, 200, 6, 7, 8, 200],
3330
[1, 2, 3, 200, 4, 5, 6, 200],
34-
]);
35-
setBlendedVisiblePixel(image, 0, 5, { color: [40, 40, 40, 40] });
36-
expect(image).toMatchImageData([
37-
[50, 255, 1, 200, 2, 3, 4, 200],
38-
[20, 30, 5, 200, 6, 7, 8, 200],
39-
[1, 2, 3, 200, 4, 5, 6, 200],
40-
]);
41-
});
42-
43-
test('GREYA image: alpha different from 255', () => {
44-
const image = testUtils.createGreyaImage([[50, 64]]);
45-
setBlendedVisiblePixel(image, 0, 0, { color: [100, 128] });
46-
const alpha = 128 + 64 * (1 - 128 / 255);
47-
const component = (100 * 128 + 50 * 64 * (1 - 128 / 255)) / alpha;
48-
expect(image).toMatchImageData([[component, alpha]]);
31+
];
32+
const image = testUtils.createGreyaImage(data);
33+
setBlendedVisiblePixel(image, 0, 5, [40, 40, 40, 40]);
34+
expect(image).toMatchImageData(data);
4935
});
5036

5137
test('asymetrical test', () => {
@@ -54,7 +40,7 @@ test('asymetrical test', () => {
5440
[20, 30, 5, 6, 7, 8],
5541
[1, 2, 3, 4, 5, 6],
5642
]);
57-
setBlendedVisiblePixel(image, 2, 0, { color: [0, 125] });
43+
setBlendedVisiblePixel(image, 2, 0, [0, 125]);
5844
expect(image).toMatchImageData([
5945
[50, 255, 1, 2, 0, 127],
6046
[20, 30, 5, 6, 7, 8],

0 commit comments

Comments
 (0)