Add new e2e command

This commit is contained in:
Dolan
2019-01-15 00:23:01 +00:00
parent d19cdcae0c
commit b37d2c141d
7 changed files with 42 additions and 9 deletions

View File

@ -10,6 +10,7 @@ script:
- npm run style - npm run style
- npm run build - npm run build
- npm run ts-node -- ./demo/demo1.ts - npm run ts-node -- ./demo/demo1.ts
- npm run e2e "My Document.docx"
- npm run ts-node -- ./demo/demo2.ts - npm run ts-node -- ./demo/demo2.ts
- npm run ts-node -- ./demo/demo3.ts - npm run ts-node -- ./demo/demo3.ts
- npm run ts-node -- ./demo/demo4.ts - npm run ts-node -- ./demo/demo4.ts
@ -19,6 +20,7 @@ script:
- npm run ts-node -- ./demo/demo8.ts - npm run ts-node -- ./demo/demo8.ts
- npm run ts-node -- ./demo/demo9.ts - npm run ts-node -- ./demo/demo9.ts
- npm run ts-node -- ./demo/demo10.ts - npm run ts-node -- ./demo/demo10.ts
- npm run e2e "My Document.docx"
- npm run ts-node -- ./demo/demo11.ts - npm run ts-node -- ./demo/demo11.ts
- npm run ts-node -- ./demo/demo12.ts - npm run ts-node -- ./demo/demo12.ts
- npm run ts-node -- ./demo/demo13.ts - npm run ts-node -- ./demo/demo13.ts
@ -39,6 +41,7 @@ script:
- npm run ts-node -- ./demo/demo28.ts - npm run ts-node -- ./demo/demo28.ts
- npm run ts-node -- ./demo/demo29.ts - npm run ts-node -- ./demo/demo29.ts
- npm run ts-node -- ./demo/demo30.ts - npm run ts-node -- ./demo/demo30.ts
- npm run e2e "My Document.docx"
- npm run ts-node -- ./demo/demo31.ts - npm run ts-node -- ./demo/demo31.ts
- npm run ts-node -- ./demo/demo32.ts - npm run ts-node -- ./demo/demo32.ts
- npm run ts-node -- ./demo/demo33.ts - npm run ts-node -- ./demo/demo33.ts

View File

@ -126,8 +126,7 @@ const arrboth = [
]; ];
arrboth.forEach((item) => { arrboth.forEach((item) => {
const para = doc.createParagraph(); doc.createImage(fs.readFileSync(item.image));
para.addImage(doc.createImage(fs.readFileSync(item.image)));
doc.createParagraph(item.comment).style("normalPara2"); doc.createParagraph(item.comment).style("normalPara2");
}); });

View File

@ -42,7 +42,7 @@ doc.addSection({
doc.createParagraph("hello in landscape"); doc.createParagraph("hello in landscape");
const header2 = doc.createHeader(); const header2 = doc.createHeader();
const pageNumber = new TextRun("Page number: ").pageNumber(); const pageNumber = new TextRun("Page number: ").pageNumber();
header2.createParagraph().addRun(pageNumber); header2.createParagraph().addRun(pageNumber);
doc.addSection({ doc.addSection({
@ -62,7 +62,9 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT, orientation: PageOrientation.PORTRAIT,
}); });
doc.createParagraph("Page number in the header must be III, because it continues from the previous section, but is defined as upper roman."); doc.createParagraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
);
doc.addSection({ doc.addSection({
headers: { headers: {

View File

@ -17,7 +17,8 @@
"typedoc": "typedoc src/index.ts", "typedoc": "typedoc src/index.ts",
"style": "prettier -l \"src/**/*.ts\"", "style": "prettier -l \"src/**/*.ts\"",
"style.fix": "npm run style -- --write", "style.fix": "npm run style -- --write",
"fix-types": "node types-absolute-fixer.js", "fix-types": "ts-node scripts/types-absolute-fixer.ts",
"e2e": "ts-node scripts/e2e.ts \"Dolan Miu CV.docx\"",
"ts-node": "ts-node" "ts-node": "ts-node"
}, },
"pre-commit": [ "pre-commit": [
@ -61,6 +62,7 @@
"devDependencies": { "devDependencies": {
"@types/chai": "^3.4.35", "@types/chai": "^3.4.35",
"@types/mocha": "^2.2.39", "@types/mocha": "^2.2.39",
"@types/request-promise": "^4.1.42",
"@types/sinon": "^4.3.1", "@types/sinon": "^4.3.1",
"awesome-typescript-loader": "^3.4.1", "awesome-typescript-loader": "^3.4.1",
"chai": "^3.5.0", "chai": "^3.5.0",
@ -74,6 +76,8 @@
"prettier": "^1.15.2", "prettier": "^1.15.2",
"prompt": "^1.0.0", "prompt": "^1.0.0",
"replace-in-file": "^3.1.0", "replace-in-file": "^3.1.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"rimraf": "^2.5.2", "rimraf": "^2.5.2",
"shelljs": "^0.7.7", "shelljs": "^0.7.7",
"sinon": "^5.0.7", "sinon": "^5.0.7",

24
scripts/e2e.ts Normal file
View File

@ -0,0 +1,24 @@
// tslint:disable:no-console
import * as fs from "fs";
import * as request from "request-promise";
async function e2e(filePath: string): Promise<void> {
console.log(`Running e2e for: ${filePath}`);
const result = await request.post({
url: "https://wt-9017166451e5dc00461b648d19f5e8da-0.sandbox.auth0-extend.com/docx-validator",
formData: {
document: fs.createReadStream(filePath),
},
});
return result;
}
e2e(process.argv[2])
.then(() => {
console.log("Success! Document is valid");
})
.catch(() => {
console.log("Error! Validation failed");
});

View File

@ -1,5 +1,5 @@
const glob = require("glob"); import * as glob from "glob";
const replace = require("replace-in-file"); import * as replace from "replace-in-file";
const files = glob.sync("build/**/*.d.ts"); const files = glob.sync("build/**/*.d.ts");
@ -14,7 +14,7 @@ for (const file of files) {
.fill("../") .fill("../")
.join(""); .join("");
return `"${backLevels}${matchSlug}"`; return `"${backLevels}${matchSlug}"`;
}, },
}); });
} }

View File

@ -22,7 +22,8 @@
"node_modules", "node_modules",
"tests", "tests",
"**/_*", "**/_*",
"demo" "demo",
"scripts"
], ],
"typedocOptions": { "typedocOptions": {
"mode": "file", "mode": "file",