diff --git a/tests/fill-odt-template.js b/tests/fill-odt-template.js index ec06b9a..a965667 100644 --- a/tests/fill-odt-template.js +++ b/tests/fill-odt-template.js @@ -36,6 +36,40 @@ Bonjoir ☀️ }); +test('basic template filling with {#if}', async t => { + const templatePath = join(import.meta.dirname, './fixtures/description-nombre.odt') + const templateContent = `Description du nombre {n} + +{#if n >5} +n est un grand nombre +{:else} +n est un petit nombre +{/if} +` + + const odtTemplate = await getOdtTemplate(templatePath) + const templateTextContent = await getOdtTextContent(odtTemplate) + t.deepEqual(templateTextContent, templateContent, 'reconnaissance du template') + + + const odtResult3 = await fillOdtTemplate(odtTemplate, {n: 3}) + const odtResult3TextContent = await getOdtTextContent(odtResult3) + t.deepEqual(odtResult3TextContent, `Description du nombre 3 + +n est un petit nombre +`) + + const odtResult8 = await fillOdtTemplate(odtTemplate, {n: 8}) + const odtResult8TextContent = await getOdtTextContent(odtResult8) + t.deepEqual(odtResult8TextContent, `Description du nombre 8 + +n est un grand nombre +`) + + +}); + + test('basic template filling with {#each}', async t => { const templatePath = join(import.meta.dirname, './fixtures/enum-courses.odt') const templateContent = `🧺 La liste de courses incroyable 🧺 diff --git a/tests/fixtures/description-nombre.odt b/tests/fixtures/description-nombre.odt new file mode 100644 index 0000000..7ede55e Binary files /dev/null and b/tests/fixtures/description-nombre.odt differ