mirror of
https://github.com/pdfme/pdfme.git
synced 2026-05-24 14:46:11 -04:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { insert } from '../../src/index';
|
|
import { pdfToImages, loadTestPDF } from '../test-helpers';
|
|
|
|
describe('E2E: insert', () => {
|
|
const fiveP = loadTestPDF('5p.pdf');
|
|
const aPdf = loadTestPDF('a.pdf');
|
|
|
|
test('insert: insert a.pdf at position 0 in 5p.pdf', async () => {
|
|
const inserted = await insert(fiveP, [{ pdf: aPdf, position: 0 }]);
|
|
|
|
const images = await pdfToImages(inserted);
|
|
for (let i = 0; i < images.length; i++) {
|
|
await expect(images[i]).toMatchImage(`insert-5p-a-at-0-result-page${i + 1}`);
|
|
}
|
|
});
|
|
|
|
test('insert: insert a.pdf at position 0 and 2 in 5p.pdf', async () => {
|
|
// Note: the second insert is done in the same buffer, so the offset changes after the first insert
|
|
const inserted = await insert(fiveP, [
|
|
{ pdf: aPdf, position: 0 },
|
|
{ pdf: aPdf, position: 2 }, // The PDF is 6 pages after the first insert
|
|
]);
|
|
|
|
const images = await pdfToImages(inserted);
|
|
for (let i = 0; i < images.length; i++) {
|
|
await expect(images[i]).toMatchImage(`insert-5p-a-at-0-and-2-result-page${i + 1}`);
|
|
}
|
|
});
|
|
});
|