Skip to content

Commit

Permalink
Add testcase for #381
Browse files Browse the repository at this point in the history
Relates to and shows that #381 is not an issue anymore.

Closes #381
  • Loading branch information
julianhille committed Oct 11, 2024
1 parent f155d00 commit 5260f72
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/AppendPagesTest.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand All @@ -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);
});
});

0 comments on commit 5260f72

Please sign in to comment.