From c15ef66e77c5b1b28e5eb1f6de5b6b3320d9f9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Fernandez?= Date: Tue, 16 Sep 2025 14:55:36 +0200 Subject: [PATCH] Test if there are two draw:image in the generated document --- scripts/odf/odt/getOdtTextContent.js | 2 +- tests/fill-odt-template/image.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/odf/odt/getOdtTextContent.js b/scripts/odf/odt/getOdtTextContent.js index 36b3160..2422eda 100644 --- a/scripts/odf/odt/getOdtTextContent.js +++ b/scripts/odf/odt/getOdtTextContent.js @@ -7,7 +7,7 @@ import {parseXML, Node} from '../../DOMUtils.js' * @param {ODTFile} odtFile * @returns {Promise} */ -async function getContentDocument(odtFile) { +export async function getContentDocument(odtFile) { const reader = new ZipReader(new Uint8ArrayReader(new Uint8Array(odtFile))); const entries = await reader.getEntries(); diff --git a/tests/fill-odt-template/image.js b/tests/fill-odt-template/image.js index 9ff6aaf..315c475 100644 --- a/tests/fill-odt-template/image.js +++ b/tests/fill-odt-template/image.js @@ -6,6 +6,7 @@ import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js' import {fillOdtTemplate, getOdtTextContent} from '../../exports.js' import { listZipEntries } from '../helpers/zip-analysis.js'; +import { getContentDocument } from '../../scripts/odf/odt/getOdtTextContent.js'; test.skip('template filling preserves images', async t => { @@ -75,6 +76,9 @@ test('insert 2 images', async t => { `Two pictures in 'Pictures/' folder are expected` ) + const odtContentDocument = await getContentDocument(odtResult) - t.fail('Two images should be in the content.xml file') + const drawImageElements = odtContentDocument.getElementsByTagName('draw:image') + t.is(drawImageElements.length, 2, 'Two draw:image elements should be in the generated document.') + }) \ No newline at end of file