Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testcase for #381 #430

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
Loading