diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts index 47a1a15d27..e69c7418c7 100644 --- a/src/file/file.spec.ts +++ b/src/file/file.spec.ts @@ -1,8 +1,11 @@ import { expect } from "chai"; +import * as sinon from "sinon"; import { Formatter } from "export/formatter"; import { File } from "./file"; +import { Paragraph } from "./paragraph"; +import { Table } from "./table"; describe("File", () => { describe("#constructor", () => { @@ -55,4 +58,24 @@ describe("File", () => { expect(tree["w:body"][1]["w:sectPr"][9]["w:footerReference"][0]._attr["w:type"]).to.equal("even"); }); }); + + describe("#addParagraph", () => { + it("should call the underlying header's addParagraph", () => { + const file = new File(); + const spy = sinon.spy(file.Document, "addParagraph"); + file.addParagraph(new Paragraph()); + + expect(spy.called).to.equal(true); + }); + }); + + describe("#addTable", () => { + it("should call the underlying header's addParagraph", () => { + const wrapper = new File(); + const spy = sinon.spy(wrapper.Document, "addTable"); + wrapper.addTable(new Table(1, 1)); + + expect(spy.called).to.equal(true); + }); + }); }); diff --git a/src/file/footer-wrapper.spec.ts b/src/file/footer-wrapper.spec.ts new file mode 100644 index 0000000000..ccea54cc6c --- /dev/null +++ b/src/file/footer-wrapper.spec.ts @@ -0,0 +1,29 @@ +import { expect } from "chai"; +import * as sinon from "sinon"; + +import { FooterWrapper } from "./footer-wrapper"; +import { Media } from "./media"; +import { Paragraph } from "./paragraph"; +import { Table } from "./table"; + +describe("FooterWrapper", () => { + describe("#addParagraph", () => { + it("should call the underlying header's addParagraph", () => { + const file = new FooterWrapper(new Media(), 1); + const spy = sinon.spy(file.Footer, "addParagraph"); + file.addParagraph(new Paragraph()); + + expect(spy.called).to.equal(true); + }); + }); + + describe("#addTable", () => { + it("should call the underlying header's addParagraph", () => { + const wrapper = new FooterWrapper(new Media(), 1); + const spy = sinon.spy(wrapper.Footer, "addTable"); + wrapper.addTable(new Table(1, 1)); + + expect(spy.called).to.equal(true); + }); + }); +}); diff --git a/src/file/header-wrapper.spec.ts b/src/file/header-wrapper.spec.ts index 4985887e33..da4f35c043 100644 --- a/src/file/header-wrapper.spec.ts +++ b/src/file/header-wrapper.spec.ts @@ -9,9 +9,9 @@ import { Table } from "./table"; describe("HeaderWrapper", () => { describe("#addParagraph", () => { it("should call the underlying header's addParagraph", () => { - const file = new HeaderWrapper(new Media(), 1); - const spy = sinon.spy(file.Header, "addParagraph"); - file.addParagraph(new Paragraph()); + const wrapper = new HeaderWrapper(new Media(), 1); + const spy = sinon.spy(wrapper.Header, "addParagraph"); + wrapper.addParagraph(new Paragraph()); expect(spy.called).to.equal(true); }); @@ -19,9 +19,9 @@ describe("HeaderWrapper", () => { describe("#addTable", () => { it("should call the underlying header's addParagraph", () => { - const file = new HeaderWrapper(new Media(), 1); - const spy = sinon.spy(file.Header, "addTable"); - file.addTable(new Table(1, 1)); + const wrapper = new HeaderWrapper(new Media(), 1); + const spy = sinon.spy(wrapper.Header, "addTable"); + wrapper.addTable(new Table(1, 1)); expect(spy.called).to.equal(true); }); diff --git a/src/import-dotx/import-dotx.ts b/src/import-dotx/import-dotx.ts index cc55eb9b75..5ac8775570 100644 --- a/src/import-dotx/import-dotx.ts +++ b/src/import-dotx/import-dotx.ts @@ -233,6 +233,7 @@ export class ImportDotx { private titlePageIsDefined(xmlData: string): boolean { const xmlObj = xml2js(xmlData, { compact: true }) as XMLElementCompact; const sectionProp = xmlObj["w:document"]["w:body"]["w:sectPr"]; + return sectionProp["w:titlePg"] !== undefined; }