Skip to content

Commit 79f4482

Browse files
committed
refactor: dirs, filenames, tests
1 parent a294538 commit 79f4482

37 files changed

+673
-588
lines changed

__tests__/create-presentation-insert-single-chart.test.ts renamed to __tests__/add-single-chart.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('create presentation and add some single charts', async () => {
1616
slide.addElement('charts', 2, 'PieChart');
1717
slide.addElement('charts', 1, 'StackedBars');
1818
})
19-
.write(`create-presentation-insert-single-chart.test.pptx`);
19+
.write(`add-single-chart.test.pptx`);
2020

2121
expect(result.slides).toBe(2);
2222
});

__tests__/create-presentation-insert-single-images.test.ts renamed to __tests__/add-single-images.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Automizer from '../src/automizer';
2-
import { revertElements } from '../src/helper/modify';
32

43
test('create presentation and add some single images', async () => {
54
const automizer = new Automizer({
@@ -16,10 +15,8 @@ test('create presentation and add some single images', async () => {
1615
.addSlide('empty', 1, (slide) => {
1716
slide.addElement('images', 2, 'imageJPG');
1817
slide.addElement('images', 2, 'imagePNG');
19-
20-
slide.modify(revertElements);
2118
})
22-
.write(`create-presentation-insert-single-images.test.pptx`);
19+
.write(`add-single-images.test.pptx`);
2320

2421
expect(result.slides).toBe(2);
2522
});

__tests__/create-presentation-charts.test.ts renamed to __tests__/add-slide-charts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('create presentation and append charts to existing charts', async () => {
1111

1212
pres.addSlide('charts', 1);
1313

14-
const result = await pres.write(`create-presentation-charts.test.pptx`);
14+
const result = await pres.write(`add-slide-charts.test.pptx`);
1515

1616
expect(result.slides).toBe(3);
1717
expect(result.charts).toBe(3);

__tests__/create-presentation-images.test.ts renamed to __tests__/add-slide-images.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('create presentation and append slides with images', async () => {
1212
pres.addSlide('images', 1);
1313
pres.addSlide('images', 2);
1414

15-
const result = await pres.write(`create-presentation-images.test.pptx`);
15+
const result = await pres.write(`add-slide-images.test.pptx`);
1616

1717
expect(result.images).toBe(5);
1818
});

__tests__/create-presentation-notes.test.ts renamed to __tests__/add-slide-notes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('create presentation and append slides with notes', async () => {
1111

1212
pres.addSlide('notes', 1);
1313

14-
const result = await pres.write(`create-presentation-notes.test.pptx`);
14+
const result = await pres.write(`add-slide-notes.test.pptx`);
1515

1616
expect(result.slides).toBe(2);
1717
});
File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Automizer, { modify } from '../src/index';
2+
3+
test('create presentation, add and modify a bubble chart.', async () => {
4+
const automizer = new Automizer({
5+
templateDir: `${__dirname}/pptx-templates`,
6+
outputDir: `${__dirname}/pptx-output`
7+
});
8+
9+
const pres = automizer
10+
.loadRoot(`RootTemplate.pptx`)
11+
.load(`ChartBubbles.pptx`, 'charts');
12+
13+
const dataBubbles = {
14+
series: [
15+
{ label: 'series s1' },
16+
{ label: 'series s2' },
17+
{ label: 'series s3' }
18+
],
19+
categories: [
20+
{ label: 'r1', values: [ {x: 10, y: 20, size: 1}, {x: 9, y: 30, size: 5}, {x: 19, y: 40, size: 1} ]},
21+
{ label: 'r2', values: [ {x: 21, y: 11, size: 4}, {x: 8, y: 31, size: 6}, {x: 18, y: 41, size: 2} ]},
22+
{ label: 'r3', values: [ {x: 22, y: 28, size: 3}, {x: 7, y: 26, size: 5}, {x: 17, y: 36, size: 1} ]},
23+
{ label: 'r4', values: [ {x: 13, y: 13, size: 2}, {x: 16, y: 28, size: 6}, {x: 26, y: 38, size: 2} ]},
24+
{ label: 'r5', values: [ {x: 18, y: 24, size: 3}, {x: 15, y: 24, size: 4}, {x: 25, y: 34, size: 2} ]},
25+
{ label: 'r6', values: [ {x: 28, y: 34, size: 1}, {x: 25, y: 34, size: 1}, {x: 35, y: 44, size: 1} ]},
26+
],
27+
}
28+
29+
const result = await pres
30+
.addSlide('charts', 1, (slide) => {
31+
slide.modifyElement('Bubbles', [
32+
modify.setChartBubbles(dataBubbles),
33+
]);
34+
})
35+
.write(`modify-chart-bubbles.test.pptx`)
36+
37+
expect(result.charts).toBe(2);
38+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Automizer, { modify } from '../src/index';
2+
3+
test('create presentation, add and modify a vertical lines chart.', async () => {
4+
const automizer = new Automizer({
5+
templateDir: `${__dirname}/pptx-templates`,
6+
outputDir: `${__dirname}/pptx-output`
7+
});
8+
9+
const pres = automizer
10+
.loadRoot(`RootTemplate.pptx`)
11+
.load(`ChartBarsStacked.pptx`, 'charts');
12+
13+
const data = {
14+
series: [
15+
{ label: 'series s1' },
16+
{ label: 'series s2' },
17+
{ label: 'series s3' }
18+
],
19+
categories: [
20+
{ label: 'item test r1', values: [ 10, 16, 12 ] },
21+
{ label: 'item test r2', values: [ 12, 18, 15 ] },
22+
{ label: 'item test r3', values: [ 14, 12, 11 ] },
23+
{ label: 'item test r4', values: [ 8, 11, 9 ] },
24+
{ label: 'item test r5', values: [ 6, 15, 7 ] },
25+
{ label: 'item test r6', values: [ 16, 16, 9 ] },
26+
],
27+
}
28+
29+
const result = await pres
30+
.addSlide('charts', 1, (slide) => {
31+
slide.modifyElement('BarsStacked', [
32+
modify.setChartData(data),
33+
]);
34+
})
35+
.write(`modify-chart-stacked-bars.test.pptx`)
36+
37+
expect(result.charts).toBe(2);
38+
});

__tests__/modify-chart-vertical-lines.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ test('create presentation, add and modify a vertical lines chart.', async () =>
1717
{ label: 'series s3' }
1818
],
1919
categories: [
20-
{ label: 'item test r1', yValue: 10, values: [10, 45, 5] },
21-
{ label: 'item test r2', yValue: 9, values: [20, 35, 6] },
22-
{ label: 'item test r3', yValue: 8, values: [15, 25, 7] },
23-
{ label: 'item test r4', yValue: 7, values: [12, 15, 8] },
24-
{ label: 'item test r5', yValue: 6, values: [8, 8, 9] },
25-
{ label: 'item test r6', yValue: 5, values: [9, 7, 10] },
26-
{ label: 'item test r7', yValue: 4, values: [6, 6, 11] },
27-
{ label: 'item test r8', yValue: 3, values: [11, 5, 12] },
28-
{ label: 'item test r9', yValue: 2, values: [12, 4, 13] },
29-
{ label: 'item test r10', yValue: 1, values: [19, 3, 14] },
20+
{ label: 'item test r1', y: 10, values: [ 10, 16, 12 ] },
21+
{ label: 'item test r2', y: 9, values: [ 12, 18, 15 ] },
22+
{ label: 'item test r3', y: 8, values: [ 14, 12, 11 ] },
23+
{ label: 'item test r4', y: 7, values: [ 8, 11, 9 ] },
24+
{ label: 'item test r5', y: 6, values: [ 6, 15,7 ] },
25+
{ label: 'item test r6', y: 5, values: [ 16, 16, 9 ] },
26+
{ label: 'item test r7', y: 4, values: [ 10, 13, 12 ] },
27+
{ label: 'item test r8', y: 3, values: [ 11, 12, 14 ] },
28+
{ label: 'item test r9', y: 2, values: [ 9, 7, 11 ] },
29+
{ label: 'item test r10', y: 1, values: [ 7, 5, 17 ] }
3030
],
3131
}
3232

__tests__/create-presentation-modify-exisiting-chart.test.ts renamed to __tests__/modify-exisiting-chart.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import Automizer from '../src/automizer';
2-
import { setChartData } from '../src/helper/modify';
3-
import { ChartData } from '../src/types/types';
1+
import Automizer, { modify } from '../src/index';
2+
import { ChartData } from '../src/types/chart-types';
43

54
test('create presentation, add slide with charts from template and modify existing chart.', async () => {
65
const automizer = new Automizer({
76
templateDir: `${__dirname}/pptx-templates`,
8-
outputDir: `${__dirname}/pptx-output`
7+
outputDir: `${__dirname}/pptx-output`,
98
});
109

1110
const pres = automizer
@@ -15,7 +14,7 @@ test('create presentation, add slide with charts from template and modify existi
1514
const result = await pres
1615
.addSlide('charts', 2, (slide) => {
1716
slide.modifyElement('ColumnChart', [
18-
setChartData(<ChartData>{
17+
modify.setChartData(<ChartData>{
1918
series: [
2019
{label: 'series 1'},
2120
{label: 'series 2'},
@@ -30,7 +29,7 @@ test('create presentation, add slide with charts from template and modify existi
3029
})
3130
]);
3231
})
33-
.write(`create-presentation-modify-existing-chart.test.pptx`);
32+
.write(`modify-existing-chart.test.pptx`);
3433

3534
expect(result.charts).toBe(3);
3635
});

0 commit comments

Comments
 (0)