Add test for insert 2 images
This commit is contained in:
parent
77fb6e998a
commit
947b722230
@ -1,5 +1,6 @@
|
|||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import {join} from 'node:path';
|
import {join} from 'node:path';
|
||||||
|
import { readFile } from 'node:fs/promises'
|
||||||
|
|
||||||
import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js'
|
import {getOdtTemplate} from '../../scripts/odf/odtTemplate-forNode.js'
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ import {fillOdtTemplate} from '../../exports.js'
|
|||||||
import { listZipEntries } from '../helpers/zip-analysis.js';
|
import { listZipEntries } from '../helpers/zip-analysis.js';
|
||||||
|
|
||||||
|
|
||||||
test('template filling preserves images', async t => {
|
test.skip('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 = {
|
||||||
@ -35,4 +36,34 @@ test('template filling preserves images', async t => {
|
|||||||
`One zip entry of the result is expected to have a name that starts with 'Pictures/'`
|
`One zip entry of the result is expected to have a name that starts with 'Pictures/'`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
test('insert 2 images', async t => {
|
||||||
|
const templatePath = join(import.meta.dirname, '../fixtures/basic-image-insertion.odt')
|
||||||
|
const odtTemplate = await getOdtTemplate(templatePath)
|
||||||
|
|
||||||
|
|
||||||
|
const photo1Path = join(import.meta.dirname, '../fixtures/pitchou-1.png')
|
||||||
|
const photo2Path = join(import.meta.dirname, '../fixtures/pitchou-2.png')
|
||||||
|
|
||||||
|
const photo1Buffer = (await readFile(photo1Path)).buffer
|
||||||
|
const photo2Buffer = (await readFile(photo2Path)).buffer
|
||||||
|
|
||||||
|
const photos = [photo1Buffer, photo2Buffer]
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
title: 'Titre de mon projet',
|
||||||
|
photos,
|
||||||
|
}
|
||||||
|
|
||||||
|
const odtResult = await fillOdtTemplate(odtTemplate, data)
|
||||||
|
const resultEntries = await listZipEntries(odtResult)
|
||||||
|
|
||||||
|
t.is(
|
||||||
|
resultEntries.filter(entry => entry.filename.startsWith('Pictures/')).length, 2,
|
||||||
|
`Two pictures in 'Pictures/' folder are expected`
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
t.fail('Two images should be in the content.xml file')
|
||||||
})
|
})
|
||||||
BIN
tests/fixtures/pitchou-1.png
vendored
Normal file
BIN
tests/fixtures/pitchou-1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 768 KiB |
BIN
tests/fixtures/pitchou-2.png
vendored
Normal file
BIN
tests/fixtures/pitchou-2.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 799 KiB |
Loading…
x
Reference in New Issue
Block a user