diff --git a/tests/fill-odt-template.js b/tests/fill-odt-template.js index 6140480..11917d0 100644 --- a/tests/fill-odt-template.js +++ b/tests/fill-odt-template.js @@ -279,6 +279,33 @@ Hiver }); +test('template filling {#each ...}{/each} within a single text node', async t => { + const templatePath = join(import.meta.dirname, './fixtures/liste-nombres.odt') + const templateContent = `Liste de nombres + +{#each nombres as n}{n} {/each} +` + + const data = { + nombres : [1,1,2,3,5,8,13,21] + } + + const odtTemplate = await getOdtTemplate(templatePath) + + const templateTextContent = await getOdtTextContent(odtTemplate) + t.deepEqual(templateTextContent, templateContent, 'reconnaissance du template') + + const odtResult = await fillOdtTemplate(odtTemplate, data) + + const odtResultTextContent = await getOdtTextContent(odtResult) + t.deepEqual(odtResultTextContent, `Liste de nombres + +1 1 2 3 5 8 13 21 +`) + +}); + + test('template filling of a table', async t => { const templatePath = join(import.meta.dirname, './fixtures/tableau-simple.odt') diff --git a/tests/fixtures/liste-nombres.odt b/tests/fixtures/liste-nombres.odt new file mode 100644 index 0000000..ae7bdfc Binary files /dev/null and b/tests/fixtures/liste-nombres.odt differ