Skip to content

Commit

Permalink
Added reproduction case for #144.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhbw committed Jun 3, 2021
1 parent 19b2c6c commit 6a7b7cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Binary file added src/__tests__/fixtures/imageExisting.docx
Binary file not shown.
26 changes: 26 additions & 0 deletions src/__tests__/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,29 @@ it('006: can inject an image from the data instead of the additionalJsContext',
expect(reportB).toBeInstanceOf(Uint8Array);
expect(reportA).toStrictEqual(reportB);
});

it('007: can inject an image in a document that already contains images (regression test for #144)', async () => {
const template = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'imageExisting.docx')
);
const buff = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'sample.png')
);
const report = await createReport({
template,
data: {
cv: { ProfilePicture: { url: 'abc' } },
},
additionalJsContext: {
getImage: () => ({
width: 6,
height: 6,
data: buff,
extension: '.png',
}),
},
});
// TODO: can only be tested by loading the result into MS Word. It will show a file corruption warning.
fs.writeFileSync('test.docx', report);
expect(report).toBeInstanceOf(Uint8Array);
});

0 comments on commit 6a7b7cd

Please sign in to comment.