From 5260f72e875edacb578faab4059a1b628bbfe781 Mon Sep 17 00:00:00 2001 From: Julian Hille Date: Sat, 12 Oct 2024 00:31:33 +0200 Subject: [PATCH] Add testcase for #381 Relates to and shows that #381 is not an issue anymore. Closes #381 --- tests/AppendPagesTest.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/AppendPagesTest.js b/tests/AppendPagesTest.js index 5f55e19e..77405d88 100644 --- a/tests/AppendPagesTest.js +++ b/tests/AppendPagesTest.js @@ -1,5 +1,7 @@ const muhammara = require("../lib/muhammara"); +const Recipe = require("../lib/Recipe"); const expect = require("chai").expect; +const fs = require("fs"); describe("AppendPagesTest", function () { it("should complete without error", function () { @@ -26,4 +28,19 @@ describe("AppendPagesTest", function () { ), ).to.throw("unable to append"); }); + + it("should free the file handle", () => { + const testFile1 = __dirname + "/output/test1.pdf"; + const testFile2 = __dirname + "/output/test2.pdf"; + const resultFile = __dirname + "/output/result.pdf"; + fs.copyFileSync(__dirname + "/TestMaterials/Original.pdf", testFile1); + fs.copyFileSync(__dirname + "/TestMaterials/Original.pdf", testFile2); + + const pdfDoc = new Recipe(testFile1, resultFile); + pdfDoc.appendPage(testFile2).endPDF(); + + // error here: Error: EBUSY: resource busy or locked, unlink + fs.unlinkSync(testFile1); + fs.unlinkSync(testFile2); + }); });