Skip to content

Commit

Permalink
test(index): check thrown error on missing binary path param
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Nov 30, 2021
1 parent bbd50d8 commit 996d3a4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/index.test.js
Expand Up @@ -37,9 +37,9 @@ switch (process.platform) {
break;
}

if (process.platform === "win32") {
describe("Constructor", () => {
test("Should convert RTF file to HTML without binary set, and use included Windows binary", async () => {
describe("Constructor", () => {
if (process.platform === "win32") {
test("Should convert RTF file to HTML without binary set on win32, and use included binary", async () => {
const unRtf = new UnRTF();
const options = {
noPictures: true,
Expand All @@ -51,8 +51,22 @@ if (process.platform === "win32") {
expect(typeof res).toBe("string");
expect(res.substring(0, 6)).toBe("<html>");
});
});
}
}

if (process.platform !== "win32") {
test(`Should return an Error object if binary path unset on ${process.platform}`, async () => {
expect.assertions(1);
try {
// eslint-disable-next-line no-unused-vars
const unRtf = new UnRTF();
} catch (err) {
expect(err.message).toBe(
`${process.platform} UnRTF binaries are not provided, please pass the installation directory as a parameter to the UnRTF instance.`
);
}
});
}
});

describe("Convert Function", () => {
let version;
Expand Down

0 comments on commit 996d3a4

Please sign in to comment.