Skip to content

Commit bd82f33

Browse files
committed
(#451) Adjusted image tests to new interface
1 parent 3ae0846 commit bd82f33

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Diff for: lib/image.class.spec.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,46 @@ afterEach(() => {
1414

1515
describe("Image class", () => {
1616
it("should return alphachannel = true for > 3 channels", () => {
17-
const SUT = new Image(200, 200, Buffer.from([123]), 4, "id");
17+
const SUT = new Image(200, 200, Buffer.from([123]), 4, "id", 4, 200 * 4);
1818
expect(SUT.hasAlphaChannel).toBeTruthy();
1919
});
2020

2121
it("should return alphachannel = false for <= 3 channels", () => {
22-
const SUT = new Image(200, 200, Buffer.from([123]), 3, "id");
22+
const SUT = new Image(200, 200, Buffer.from([123]), 3, "id", 4, 200 * 4);
2323
expect(SUT.hasAlphaChannel).toBeFalsy();
2424
});
2525
it("should return alphachannel = false for <= 3 channels", () => {
26-
const SUT = new Image(200, 200, Buffer.from([123]), 2, "id");
26+
const SUT = new Image(200, 200, Buffer.from([123]), 2, "id", 4, 200 * 4);
2727
expect(SUT.hasAlphaChannel).toBeFalsy();
2828
});
2929
it("should return alphachannel = false for <= 3 channels", () => {
30-
const SUT = new Image(200, 200, Buffer.from([123]), 1, "id");
30+
const SUT = new Image(200, 200, Buffer.from([123]), 1, "id", 4, 200 * 4);
3131
expect(SUT.hasAlphaChannel).toBeFalsy();
3232
});
3333

3434
it("should throw for <= 0 channels", () => {
35-
expect(() => new Image(200, 200, Buffer.from([123]), 0, "id")).toThrowError(
36-
"Channel <= 0"
37-
);
35+
expect(
36+
() => new Image(200, 200, Buffer.from([123]), 0, "id", 4, 200 * 4)
37+
).toThrowError("Channel <= 0");
3838
});
3939

4040
it("should have a default pixel density of 1.0", () => {
41-
const SUT = new Image(200, 200, Buffer.from([123]), 1, "id");
41+
const SUT = new Image(200, 200, Buffer.from([123]), 1, "id", 4, 200 * 4);
4242
expect(SUT.pixelDensity).toEqual({ scaleX: 1.0, scaleY: 1.0 });
4343
});
4444

4545
describe("Colormode", () => {
4646
it("should not try to convert an image to BGR if it already has the correct color mode", async () => {
4747
// GIVEN
48-
const bgrImage = new Image(100, 100, Buffer.from([]), 3, "testImage");
48+
const bgrImage = new Image(
49+
100,
50+
100,
51+
Buffer.from([]),
52+
3,
53+
"testImage",
54+
4,
55+
200 * 4
56+
);
4957

5058
// WHEN
5159
const convertedImage = await bgrImage.toBGR();
@@ -63,6 +71,8 @@ describe("Image class", () => {
6371
Buffer.from([]),
6472
3,
6573
"testImage",
74+
4,
75+
200 * 4,
6676
ColorMode.RGB
6777
);
6878

@@ -78,7 +88,7 @@ describe("Image class", () => {
7888
describe("isImage typeguard", () => {
7989
it("should identify an Image", () => {
8090
// GIVEN
81-
const img = new Image(100, 100, Buffer.from([]), 4, "foo");
91+
const img = new Image(100, 100, Buffer.from([]), 4, "foo", 4, 200 * 4);
8292

8393
// WHEN
8494
const result = isImage(img);

0 commit comments

Comments
 (0)