-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
replace-tagged-text.test.ts
95 lines (89 loc) · 2.3 KB
/
replace-tagged-text.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import Automizer, { modify } from '../src/index';
const bulletPoints = ['first line', 'second line', 'third line'].join(`
`);
test('create presentation, replace tagged text.', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
});
const pres = automizer.loadRoot(`RootTemplate.pptx`).load(`TextReplace.pptx`);
const result = await pres
.addSlide('TextReplace.pptx', 1, (slide) => {
slide.modifyElement('setText', modify.setText('Test'));
slide.modifyElement(
'replaceText',
modify.replaceText(
[
{
replace: 'replace',
by: {
text: 'Apples',
},
},
{
replace: 'by',
by: {
text: 'Bananas',
},
},
{
replace: 'replacement',
by: [
{
text: 'Really!',
style: {
size: 10000,
color: {
type: 'srgbClr',
value: 'ccaa4f',
},
},
},
{
text: 'Fine!',
style: {
size: 10000,
color: {
type: 'schemeClr',
value: 'accent2',
},
},
},
],
},
],
{
openingTag: '{{',
closingTag: '}}',
},
),
);
})
.addSlide('TextReplace.pptx', 2, (slide) => {
slide.modifyElement(
'replaceTextBullet1',
modify.replaceText(
[
{
replace: 'bullet1',
by: {
text: bulletPoints,
},
},
{
replace: 'bullet2',
by: {
text: bulletPoints,
},
},
],
{
openingTag: '{{',
closingTag: '}}',
},
),
);
})
.write(`replace-tagged-text.test.pptx`);
// expect(result.tables).toBe(2); // TODO: fixture for pptx-output
});