|
| 1 | +import Automizer, { modify } from '../src/index'; |
| 2 | + |
| 3 | +test('create presentation, add and modify an existing table.', async () => { |
| 4 | + const automizer = new Automizer({ |
| 5 | + templateDir: `${__dirname}/pptx-templates`, |
| 6 | + outputDir: `${__dirname}/pptx-output`, |
| 7 | + }); |
| 8 | + |
| 9 | + const data1 = { |
| 10 | + body: [ |
| 11 | + { label: 'item test r1', values: ['test1', 10, 16, 12] }, |
| 12 | + { label: 'item test r2', values: ['test2', 12, 18, 15] }, |
| 13 | + { label: 'item test r3', values: ['test3', 14, 12, 11] }, |
| 14 | + // { label: 'item test r4', values: ['test4', 14, 12, 11] }, |
| 15 | + // { label: 'item test r5', values: ['test5', 14, 12, 11] }, |
| 16 | + // { label: 'item test r6', values: ['test6', 999, 12, 11] }, |
| 17 | + // { label: 'item test r6', values: ['test7', 999, 12, 11] }, |
| 18 | + // { label: 'item test r6', values: ['test8', 999, 12, 11] }, |
| 19 | + // { label: 'item test r6', values: ['test9', 999, 12, 11] }, |
| 20 | + ], |
| 21 | + }; |
| 22 | + |
| 23 | + const pres = automizer |
| 24 | + .loadRoot(`RootTemplate.pptx`) |
| 25 | + .load(`SlideWithTables.pptx`, 'tables'); |
| 26 | + |
| 27 | + const result = await pres |
| 28 | + .addSlide('tables', 1, (slide) => { |
| 29 | + slide.modifyElement('TableWithHeader', [modify.setTableData(data1)]); |
| 30 | + }) |
| 31 | + .write(`modify-existing-table.test.pptx`); |
| 32 | + |
| 33 | + // expect(result.tables).toBe(2); // tbd |
| 34 | +}); |
0 commit comments