fix(core): update
This commit is contained in:
28
test/test.ts
28
test/test.ts
@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user