diff --git a/tests/fill-odt-template/image.js b/tests/fill-odt-template/image.js index 8e67919..543533b 100644 --- a/tests/fill-odt-template/image.js +++ b/tests/fill-odt-template/image.js @@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises' import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js' -import {fillOdtTemplate} from '../../exports.js' +import {fillOdtTemplate, getOdtTextContent} from '../../exports.js' import { listZipEntries } from '../helpers/zip-analysis.js'; @@ -40,8 +40,18 @@ test.skip('template filling preserves images', async t => { test('insert 2 images', async t => { const templatePath = join(import.meta.dirname, '../fixtures/basic-image-insertion.odt') - const odtTemplate = await getOdtTemplate(templatePath) + + const odtTemplate = await getOdtTemplate(templatePath) + const templateContent = `{title} + +{#each photos as photo} +{#image photo} +{/each} +` + const templateTextContent = await getOdtTextContent(odtTemplate) + + t.is(templateTextContent, templateContent, 'reconnaissance du template') const photo1Path = join(import.meta.dirname, '../fixtures/pitchou-1.png') const photo2Path = join(import.meta.dirname, '../fixtures/pitchou-2.png') @@ -58,7 +68,8 @@ test('insert 2 images', async t => { const odtResult = await fillOdtTemplate(odtTemplate, data) const resultEntries = await listZipEntries(odtResult) - + + t.is( resultEntries.filter(entry => entry.filename.startsWith('Pictures/')).length, 2, `Two pictures in 'Pictures/' folder are expected`