fix(core): update

This commit is contained in:
2021-10-14 10:59:45 +02:00
parent 56fa53b701
commit 8a308fa9e3
6 changed files with 18022 additions and 2453 deletions

View File

@ -25,18 +25,28 @@ tap.test('should create a pdf from website as single page PDF', async () => {
});
tap.test('should create a valid PDFResult', async () => {
const pdfResult = await testSmartPdf.getFullWebsiteAsSinglePdf(
'https://maintainedby.lossless.com'
);
expect(pdfResult.buffer).to.be.instanceOf(Buffer);
const fs = await import('fs');
const writePDfToDisk = async (urlArg: string, fileName: string) => {
const pdfResult = await testSmartPdf.getFullWebsiteAsSinglePdf(urlArg);
expect(pdfResult.buffer).to.be.instanceOf(Buffer);
const fs = await import('fs');
if (!fs.existsSync('.nogit/')) {
fs.mkdirSync('.nogit/');
}
fs.writeFileSync('.nogit/sample.pdf', pdfResult.buffer);
if (!fs.existsSync('.nogit/')) {
fs.mkdirSync('.nogit/');
}
fs.writeFileSync(`.nogit/${fileName}`, pdfResult.buffer);
};
await writePDfToDisk('https://maintainedby.lossless.com/', '1.pdf')
await writePDfToDisk('https://lossless.com/', '2.pdf')
});
tap.test('should combine pdfs', async () => {
const fs = await import('fs');
const buffer1 = fs.readFileSync('.nogit/1.pdf');
const buffer2 = fs.readFileSync('.nogit/2.pdf');
fs.writeFileSync(`.nogit/combined.pdf`, await testSmartPdf.mergePdfBuffers([buffer1, buffer2]));
})
tap.test('should be able to close properly', async () => {
await testSmartPdf.stop();
});