2017-12-05 00:16:21 +00:00
|
|
|
/* tslint:disable:typedef space-before-function-paren */
|
2017-03-07 13:36:12 +01:00
|
|
|
import * as fs from "fs";
|
2017-03-09 22:56:08 +00:00
|
|
|
|
2017-03-07 22:15:53 +00:00
|
|
|
import { Document } from "../../docx/document";
|
|
|
|
import { Paragraph } from "../../docx/paragraph";
|
2017-03-09 22:56:08 +00:00
|
|
|
import { LocalPacker } from "../../export/packer/local";
|
|
|
|
import { Properties } from "../../properties";
|
2017-03-07 22:15:53 +00:00
|
|
|
import { DefaultStylesFactory } from "../../styles/factory";
|
2016-03-31 18:03:16 +01:00
|
|
|
|
2017-12-06 01:03:14 +00:00
|
|
|
describe("LocalPacker", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let packer: LocalPacker;
|
|
|
|
let stylesFactory: DefaultStylesFactory;
|
2016-03-31 18:03:16 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-03-09 22:56:08 +00:00
|
|
|
const document = new Document();
|
|
|
|
const paragraph = new Paragraph("test text");
|
|
|
|
const heading = new Paragraph("Hello world").heading1();
|
2016-05-10 00:32:00 +01:00
|
|
|
document.addParagraph(new Paragraph("title").title());
|
2016-05-09 03:44:16 +01:00
|
|
|
document.addParagraph(heading);
|
2016-05-10 00:32:00 +01:00
|
|
|
document.addParagraph(new Paragraph("heading 2").heading2());
|
2016-04-05 22:11:21 +01:00
|
|
|
document.addParagraph(paragraph);
|
2017-03-09 22:56:08 +00:00
|
|
|
const properties = new Properties({
|
2016-07-19 18:45:07 +01:00
|
|
|
creator: "Dolan Miu",
|
2016-04-08 23:01:50 +01:00
|
|
|
revision: "1",
|
2017-03-09 22:56:08 +00:00
|
|
|
lastModifiedBy: "Dolan Miu",
|
2016-04-05 01:49:12 +01:00
|
|
|
});
|
2016-05-09 03:44:16 +01:00
|
|
|
stylesFactory = new DefaultStylesFactory();
|
2016-07-04 18:47:13 +01:00
|
|
|
packer = new LocalPacker(document, stylesFactory.newInstance(), properties);
|
2016-03-31 18:03:16 +01:00
|
|
|
});
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#pack()", () => {
|
2017-12-06 01:32:57 +00:00
|
|
|
it("should create a standard docx file", async function () {
|
2016-07-01 22:09:55 +01:00
|
|
|
this.timeout(99999999);
|
2017-12-06 01:32:57 +00:00
|
|
|
await packer.pack("build-tests/tests/test");
|
|
|
|
fs.statSync("build-tests/tests/test.docx");
|
2016-03-31 18:03:16 +01:00
|
|
|
});
|
2017-12-06 01:03:14 +00:00
|
|
|
});
|
2017-12-05 00:16:21 +00:00
|
|
|
|
2017-12-06 01:03:14 +00:00
|
|
|
describe("#packPdf", () => {
|
2017-12-05 00:16:21 +00:00
|
|
|
it("should create a standard PDF file", async function () {
|
|
|
|
this.timeout(99999999);
|
|
|
|
|
|
|
|
await packer.packPdf("build-tests/tests/pdf-test");
|
|
|
|
fs.statSync("build-tests/tests/pdf-test.pdf");
|
|
|
|
});
|
2016-03-31 18:03:16 +01:00
|
|
|
});
|
2017-03-09 22:56:08 +00:00
|
|
|
});
|