Skip to content

Commit 27932bc

Browse files
committed
Increase test coverage
1 parent 0e4b90a commit 27932bc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/provider/io/jimp-image-writer.class.spec.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jest.mock("jimp", () => {
2222
afterEach(() => jest.resetAllMocks());
2323

2424
describe("Jimp image writer", () => {
25-
it("should reject on writing failures", async () => {
25+
it("should resolve on writing", async () => {
2626
// GIVEN
2727
const outputFileName = "/does/not/compute.png";
2828
const outputFile = new Image(
@@ -48,4 +48,28 @@ describe("Jimp image writer", () => {
4848
expect(writeMock).toHaveBeenCalledTimes(1);
4949
expect(writeMock).toHaveBeenCalledWith(outputFileName);
5050
});
51+
52+
it("should reject on writing failures", () => {
53+
// GIVEN
54+
const outputFileName = "/does/not/compute.png";
55+
const outputFile = new Image(
56+
100,
57+
200,
58+
Buffer.from([]),
59+
3,
60+
outputFileName,
61+
4,
62+
100 * 4
63+
);
64+
const writeMock = jest.fn(() => Promise.reject("write error"));
65+
Jimp.prototype.scan = jest.fn();
66+
Jimp.prototype.writeAsync = writeMock;
67+
const SUT = new ImageWriter();
68+
69+
// WHEN
70+
const result = SUT.store({ image: outputFile, path: outputFileName });
71+
72+
// THEN
73+
expect(result).rejects.toBe("write error");
74+
});
5175
});

0 commit comments

Comments
 (0)