Commit 065e52e9 authored by Tomáš Hübelbauer's avatar Tomáš Hübelbauer

Add a basic PowerPoint test

parent 30566b0a
......@@ -2,4 +2,10 @@
> Planned development:
## Add more tests of varying complexity for all of Word, Excel and PowerPoint
## Add a test for the skip file if unchanged logic
## Add a test that checks for the presence of the generated warning
## Add a test for disposing of abandoned extraction directories
## Add a test for the Git hook code
......@@ -7,6 +7,7 @@ import util from 'util';
import testWordBasic from './tests/word-basic';
import testExcelBasic from './tests/excel-basic';
import testPowerPointBasic from './tests/powerPoint-basic';
const mkdtemp = util.promisify(fs.mkdtemp);
const exec = util.promisify(child_process.exec);
......@@ -15,7 +16,7 @@ async function test() {
console.log('Running Office tests…\n');
await run(testWordBasic, 'docx', 'Word - basic');
await run(testExcelBasic, 'xlsx', 'Excel - basic');
// TODO: Add more tests.
await run(testPowerPointBasic, 'pptx', 'PowerPoint - basic');
}
test();
......
......@@ -17,7 +17,7 @@ export default function(excel) {
return async (dir) => {
const spans = String(await readFile(path.join(dir, 'xl/sharedStrings.xml.txt'))).split('\n');
if (spans[1] !== 'Hello,' || spans[2] !== 'World!' || spans[3] !== 'Hi,' || spans[4] !== 'there' || spans[5] !== '\r') {
throw new Error('The resulting TXT file did not have matching spans to what was inserted.');
throw new Error('The resulting TXT file did not have matching spans to what was inserted.\n' + spans.join('\n'));
}
};
}
import fs from 'fs';
import util from 'util';
import path from 'path';
const readFile = util.promisify(fs.readFile);
export default function(powerPoint) {
const slide = powerPoint.makeNewSlide();
slide.addText('Hello,');
slide.addText('World!');
const titleSlide = powerPoint.makeTitleSlide();
titleSlide.setTitle('Hello hello hello');
titleSlide.setSubTitle('It is a-me Mario');
return async (dir) => {
const slideSpans = String(await readFile(path.join(dir, 'ppt/slides/slide1.xml.txt'))).split('\n');
if (slideSpans[1] !== 'Hello,' || slideSpans[2] !== 'World!' || slideSpans[3] !== '\r') {
throw new Error('The resulting TXT file for slide did not have matching spans to what was inserted.\n', slideSpans.join('\n'));
}
const titleSlideSpans = String(await readFile(path.join(dir, 'ppt/slides/slide2.xml.txt'))).split('\n');
if (titleSlideSpans[1] !== 'Hello hello hello' || titleSlideSpans[2] !== 'It is a-me Mario' || titleSlideSpans[5] !== '\r') {
throw new Error('The resulting TXT file for title slide did not have matching spans to what was inserted.\n', titleSlideSpans.join('\n'));
}
};
}
......@@ -16,7 +16,7 @@ export default function(word) {
return async (dir) => {
const spans = String(await readFile(path.join(dir, 'word/document.xml.txt'))).split('\n');
if (spans[1] !== 'Hello,' || spans[2] !== 'World!' || spans[3] !== 'Hi,' || spans[4] !== 'it is me, Tom!' || spans[5] !== '\r') {
throw new Error('The resulting TXT file did not have matching spans to what was inserted.');
throw new Error('The resulting TXT file did not have matching spans to what was inserted.\n' + spans.join('\n'));
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment