-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.test.js
34 lines (27 loc) · 1.36 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const pdftopic = require("./");
const fs = require('fs');
test('converting [email protected] (single file)', async () => {
const pdf = fs.readFileSync('./pdf_files/ilyes.pdf');
const result = await pdftopic.pdftobuffer(pdf, 0);
expect(result).not.toBeNull();
});
test('converting [email protected] (specific files)', async () => {
const pdf = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
const result = await pdftopic.pdftobuffer(pdf, [ 1, 3 ]);
expect(result).not.toBeNull();
});
test('converting [email protected] (multiple file)', async () => {
const pdf = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
const result = await pdftopic.pdftobuffer(pdf, "all");
expect(result).not.toBeNull();
});
test('converting [email protected] (all images in one image)', async () => {
const file1 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-0.png');
const file2 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-1.png');
const file3 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-2.png');
const file4 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-3.png');
const allfiles = [ file1, file2, file3, file4 ];
const result = await pdftopic.bufferstoappend(allfiles);
expect(result).not.toBeNull();
fs.writeFileSync('./curriculum_vitae.png', result);
});