Skip to content

Commit

Permalink
chore(test): replace (tagged) bulleted text
Browse files Browse the repository at this point in the history
  • Loading branch information
singerla committed Nov 6, 2024
1 parent d964d73 commit 866ec77
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Binary file added __tests__/pptx-templates/TextReplaceBullets.pptx
Binary file not shown.
61 changes: 61 additions & 0 deletions __tests__/replace-nested-bullets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Automizer, { modify } from '../src/index';

const bulletPoints = ['first line', 'second line', 'third line'].join(`\n`);
const bulletPoints2 = ['first line-2', 'second line-2'].join(`\n`);

test('create presentation, replace tagged and untagged nested bulleted text.', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
removeExistingSlides: true,
});

const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`TextReplaceNestedBullets.pptx`);

await pres
.addSlide('TestNestedBullets.pptx', 1, (slide) => {
slide.modifyElement(
'@AutomateBullets',
modify.replaceText(
[
{
replace: 'bullet1',
by: {
text: bulletPoints,
},
},
{
replace: 'bullet2',
by: {
text: bulletPoints,
},
},
{
replace: 'bullet2-1',
by: {
text: bulletPoints2,
},
},
],
{
openingTag: '{{',
closingTag: '}}',
},
),
);
})
.addSlide('TestNestedBullets.pptx', 2, (slide) => {
slide.modifyElement(
'@AutomateNestedBullets',
modify.setBulletList([
'Test1',
'Test 2',
['Test 3-1', 'Test 3-2', ['Test 3-3-1', 'Test 3-3-2']],
'Test 4',
]),
);
})
.write(`replace-nested-bullets.test.pptx`);
});

0 comments on commit 866ec77

Please sign in to comment.