Skip to content

Commit

Permalink
write initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
ACHP committed Jan 28, 2025
1 parent c96f3b1 commit 087c36d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Binary file not shown.
32 changes: 32 additions & 0 deletions src/__tests__/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,35 @@ it('011 correctly inserts the optional image caption', async () => {
};
expect(await createReport(opts, 'XML')).toMatchSnapshot();
});

it('can inject image in document that already contained image with same extension but uppercase', async () => {
const template = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'existingUppercaseJPEGExtension.docx')
);
const buff = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'sample.jpg')
);

const report = await createReport({
template,
cmdDelimiter: '+++',
data: {
injectImg: () => ({
width: 6,
height: 6,
data: buff,
extension: '.jpg',
}),
},
});

const jsZip = await JSZip.loadAsync(report);

const contentType = await jsZip.file('[Content_Types].xml')?.async('string');

console.log('contentType', contentType);
expect(contentType).toBeDefined();
// expect(contentType).toMatchSnapshot();

fs.writeFileSync('output.docx', report);
});

0 comments on commit 087c36d

Please sign in to comment.