tests passing

This commit is contained in:
David Bruant 2025-04-26 19:55:08 +02:00
parent 4882c39e32
commit 94dbd2c54e
2 changed files with 18 additions and 16 deletions

View File

@ -261,19 +261,17 @@ function fillTemplatedOdtElement(rootElement, data, Node){
if(match){
// split 3-way : before-match, match and after-match
let afterMatchTextNode
if(match[0].length < remainingText.length){
afterMatchTextNode = currentNode.splitText(match.index + match[0].length)
let afterMatchTextNode = currentNode.splitText(match.index + match[0].length)
if(afterMatchTextNode.textContent && afterMatchTextNode.textContent.length >= 1){
remainingText = afterMatchTextNode.textContent
}
else{
remainingText = ''
}
}
// per spec, currentNode now contains before-match and match text
if(match.index > 0){
currentNode.splitText(match.index)
}
@ -286,6 +284,10 @@ function fillTemplatedOdtElement(rootElement, data, Node){
remainingText = ''
}
}
else{
remainingText = ''
}
}
}
else{

View File

@ -73,7 +73,7 @@ Pâtes à lasagne (fraîches !)
});
test.skip('Filling with {#each} and non-iterable value results in no error and empty result', async t => {
test('Filling with {#each} and non-iterable value results in no error and empty result', async t => {
const templatePath = join(import.meta.dirname, './fixtures/enum-courses.odt')
const templateContent = `🧺 La liste de courses incroyable 🧺
@ -103,7 +103,7 @@ test.skip('Filling with {#each} and non-iterable value results in no error and e
});
test.skip('template filling with {#each} generating a list', async t => {
test('template filling with {#each} generating a list', async t => {
const templatePath = join(import.meta.dirname, './fixtures/liste-courses.odt')
const templateContent = `🧺 La liste de courses incroyable 🧺
@ -140,7 +140,7 @@ test.skip('template filling with {#each} generating a list', async t => {
});
test.skip('template filling with 2 sequential {#each}', async t => {
test('template filling with 2 sequential {#each}', async t => {
const templatePath = join(import.meta.dirname, './fixtures/liste-fruits-et-légumes.odt')
const templateContent = `Liste de fruits et légumes
@ -192,7 +192,7 @@ Poivron 🫑
});
test.skip('template filling with nested {#each}s', async t => {
test('template filling with nested {#each}s', async t => {
const templatePath = join(import.meta.dirname, './fixtures/légumes-de-saison.odt')
const templateContent = `Légumes de saison
@ -305,7 +305,7 @@ Les nombres : 1 1 2 3 5 8 13 21  !!
test.skip('template filling of a table', async t => {
test('template filling of a table', async t => {
const templatePath = join(import.meta.dirname, './fixtures/tableau-simple.odt')
const templateContent = `Évolution énergie en kWh par personne en France
@ -366,7 +366,7 @@ Année
});
test.skip('template filling preserves images', async t => {
test('template filling preserves images', async t => {
const templatePath = join(import.meta.dirname, './fixtures/template-avec-image.odt')
const data = {