-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
add-external-image.test.ts
43 lines (36 loc) · 1.41 KB
/
add-external-image.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Automizer from '../src/automizer';
import { ModifyImageHelper, ModifyShapeHelper } from '../src';
import { CmToDxa } from '../src/helper/modify-helper';
test('Load external media, add/modify image and set image target', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/../__tests__/pptx-templates`,
outputDir: `${__dirname}/../__tests__/pptx-output`,
mediaDir: `${__dirname}/../__tests__/media`,
removeExistingSlides: true,
cleanup: true,
});
const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.loadMedia([`feather.png`, `test.png`])
.loadMedia(`test.png`, `${__dirname}/../__tests__/media`, 'pre_')
.load(`SlideWithShapes.pptx`, 'shapes')
.load(`SlideWithImages.pptx`, 'images');
pres.addSlide('shapes', 1, (slide) => {
slide.addElement('images', 2, 'imagePNGduotone', [
ModifyShapeHelper.setPosition({
w: CmToDxa(5),
h: CmToDxa(3),
}),
ModifyImageHelper.setRelationTarget('feather.png'),
]);
});
pres.addSlide('images', 1, (slide) => {
slide.modifyElement('Grafik 5', [
ModifyImageHelper.setRelationTarget('pre_test.png'),
]);
});
const result = await pres.write(`add-external-image.test.pptx`);
// expect a 5x3cm light-blue duotone feather instead of imagePNG cord loop on page 1
// expect imagePNG cord loop on page 2 instead of cut tree jpg
expect(result.images).toBe(3);
});