Ajout d'un test pour vérifier que le texte du template est bon
This commit is contained in:
parent
ef5da802db
commit
a4173b1249
@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises'
|
|||||||
|
|
||||||
import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js'
|
import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js'
|
||||||
|
|
||||||
import {fillOdtTemplate} from '../../exports.js'
|
import {fillOdtTemplate, getOdtTextContent} from '../../exports.js'
|
||||||
import { listZipEntries } from '../helpers/zip-analysis.js';
|
import { listZipEntries } from '../helpers/zip-analysis.js';
|
||||||
|
|
||||||
|
|
||||||
@ -40,8 +40,18 @@ test.skip('template filling preserves images', async t => {
|
|||||||
|
|
||||||
test('insert 2 images', async t => {
|
test('insert 2 images', async t => {
|
||||||
const templatePath = join(import.meta.dirname, '../fixtures/basic-image-insertion.odt')
|
const templatePath = join(import.meta.dirname, '../fixtures/basic-image-insertion.odt')
|
||||||
const odtTemplate = await getOdtTemplate(templatePath)
|
|
||||||
|
|
||||||
|
const odtTemplate = await getOdtTemplate(templatePath)
|
||||||
|
const templateContent = `{title}
|
||||||
|
|
||||||
|
{#each photos as photo}
|
||||||
|
{#image photo}
|
||||||
|
{/each}
|
||||||
|
`
|
||||||
|
const templateTextContent = await getOdtTextContent(odtTemplate)
|
||||||
|
|
||||||
|
t.is(templateTextContent, templateContent, 'reconnaissance du template')
|
||||||
|
|
||||||
const photo1Path = join(import.meta.dirname, '../fixtures/pitchou-1.png')
|
const photo1Path = join(import.meta.dirname, '../fixtures/pitchou-1.png')
|
||||||
const photo2Path = join(import.meta.dirname, '../fixtures/pitchou-2.png')
|
const photo2Path = join(import.meta.dirname, '../fixtures/pitchou-2.png')
|
||||||
@ -58,7 +68,8 @@ test('insert 2 images', async t => {
|
|||||||
|
|
||||||
const odtResult = await fillOdtTemplate(odtTemplate, data)
|
const odtResult = await fillOdtTemplate(odtTemplate, data)
|
||||||
const resultEntries = await listZipEntries(odtResult)
|
const resultEntries = await listZipEntries(odtResult)
|
||||||
|
|
||||||
|
|
||||||
t.is(
|
t.is(
|
||||||
resultEntries.filter(entry => entry.filename.startsWith('Pictures/')).length, 2,
|
resultEntries.filter(entry => entry.filename.startsWith('Pictures/')).length, 2,
|
||||||
`Two pictures in 'Pictures/' folder are expected`
|
`Two pictures in 'Pictures/' folder are expected`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user