Skip to content

Commit

Permalink
tests(index): add tests for uncovered branches
Browse files Browse the repository at this point in the history
  • Loading branch information
Frazer Smith committed Apr 10, 2020
1 parent a6842a2 commit 720eab9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ describe('pdfDetach function', () => {
await clean();
});

test('Should list embedded files', async () => {
const poppler = new Poppler();
const options = {
listEmbedded: true
}
const attachmentFile = `${testDirectory}pdf_1.3_NHS_Constitution_attached_detach.pdf`;

await poppler
.pdfDetach(options, attachmentFile)
.then((res) => {
expect(typeof res).toBe('string');
});
});

test('Should return an Error object if file passed not PDF format', async () => {
const poppler = new Poppler();
const testTxtFile = `${testDirectory}test.txt`;
Expand Down Expand Up @@ -325,6 +339,17 @@ describe('pdfInfo function', () => {
await clean();
});

test('Should list info of PDF file', async () => {
const poppler = new Poppler();
const attachmentFile = `${testDirectory}pdf_1.3_NHS_Constitution_attached_detach.pdf`;

await poppler
.pdfInfo(undefined, attachmentFile)
.then((res) => {
expect(typeof res).toBe('string');
});
});

test('Should return an Error object if file passed not PDF format', async () => {
const poppler = new Poppler();
const testTxtFile = `${testDirectory}test.txt`;
Expand Down Expand Up @@ -849,6 +874,19 @@ describe('pdfUnite function', () => {
});
});

test('Should return an Error object if a PDF file and non-PDF file are attempted to be merged', async () => {
const poppler = new Poppler();
const files = [
`${testDirectory}test.txt`,
`${testDirectory}pdf_1.7_NHS_Constitution_Handbook.pdf`
];

expect.assertions(1);
await poppler.pdfUnite(undefined, files).catch((err) => {
expect(err.message.substring(0, 15)).toBe('Command failed:');
});
});

test('Should return an Error object if invalid value types provided for an option are passed to function', async () => {
const poppler = new Poppler();
const files = [
Expand Down

0 comments on commit 720eab9

Please sign in to comment.