Adding {#if} test case
This commit is contained in:
parent
3da7f29cb0
commit
9cb48a811a
@ -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 🧺
|
||||
|
||||
BIN
tests/fixtures/description-nombre.odt
vendored
Normal file
BIN
tests/fixtures/description-nombre.odt
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user