tests passing
This commit is contained in:
parent
4882c39e32
commit
94dbd2c54e
@ -261,25 +261,27 @@ function fillTemplatedOdtElement(rootElement, data, Node){
|
|||||||
if(match){
|
if(match){
|
||||||
// split 3-way : before-match, match and after-match
|
// split 3-way : before-match, match and after-match
|
||||||
|
|
||||||
let afterMatchTextNode
|
|
||||||
|
|
||||||
if(match[0].length < remainingText.length){
|
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){
|
if(afterMatchTextNode.textContent && afterMatchTextNode.textContent.length >= 1){
|
||||||
remainingText = afterMatchTextNode.textContent
|
remainingText = afterMatchTextNode.textContent
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
remainingText = ''
|
remainingText = ''
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// per spec, currentNode now contains before-match and match text
|
||||||
|
|
||||||
|
if(match.index > 0){
|
||||||
|
currentNode.splitText(match.index)
|
||||||
|
}
|
||||||
|
|
||||||
// per spec, currentNode now contains before-match and match text
|
if(afterMatchTextNode){
|
||||||
if(match.index > 0){
|
currentNode = afterMatchTextNode
|
||||||
currentNode.splitText(match.index)
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
if(afterMatchTextNode){
|
remainingText = ''
|
||||||
currentNode = afterMatchTextNode
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@ -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 templatePath = join(import.meta.dirname, './fixtures/enum-courses.odt')
|
||||||
const templateContent = `🧺 La liste de courses incroyable 🧺
|
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 templatePath = join(import.meta.dirname, './fixtures/liste-courses.odt')
|
||||||
const templateContent = `🧺 La liste de courses incroyable 🧺
|
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 templatePath = join(import.meta.dirname, './fixtures/liste-fruits-et-légumes.odt')
|
||||||
const templateContent = `Liste de fruits et légumes
|
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 templatePath = join(import.meta.dirname, './fixtures/légumes-de-saison.odt')
|
||||||
const templateContent = `Légumes de saison
|
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 templatePath = join(import.meta.dirname, './fixtures/tableau-simple.odt')
|
||||||
const templateContent = `Évolution énergie en kWh par personne en France
|
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 templatePath = join(import.meta.dirname, './fixtures/template-avec-image.odt')
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user