Add tests
This commit is contained in:
@ -1,8 +1,11 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
import { File } from "./file";
|
import { File } from "./file";
|
||||||
|
import { Paragraph } from "./paragraph";
|
||||||
|
import { Table } from "./table";
|
||||||
|
|
||||||
describe("File", () => {
|
describe("File", () => {
|
||||||
describe("#constructor", () => {
|
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");
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
29
src/file/footer-wrapper.spec.ts
Normal file
29
src/file/footer-wrapper.spec.ts
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -9,9 +9,9 @@ import { Table } from "./table";
|
|||||||
describe("HeaderWrapper", () => {
|
describe("HeaderWrapper", () => {
|
||||||
describe("#addParagraph", () => {
|
describe("#addParagraph", () => {
|
||||||
it("should call the underlying header's addParagraph", () => {
|
it("should call the underlying header's addParagraph", () => {
|
||||||
const file = new HeaderWrapper(new Media(), 1);
|
const wrapper = new HeaderWrapper(new Media(), 1);
|
||||||
const spy = sinon.spy(file.Header, "addParagraph");
|
const spy = sinon.spy(wrapper.Header, "addParagraph");
|
||||||
file.addParagraph(new Paragraph());
|
wrapper.addParagraph(new Paragraph());
|
||||||
|
|
||||||
expect(spy.called).to.equal(true);
|
expect(spy.called).to.equal(true);
|
||||||
});
|
});
|
||||||
@ -19,9 +19,9 @@ describe("HeaderWrapper", () => {
|
|||||||
|
|
||||||
describe("#addTable", () => {
|
describe("#addTable", () => {
|
||||||
it("should call the underlying header's addParagraph", () => {
|
it("should call the underlying header's addParagraph", () => {
|
||||||
const file = new HeaderWrapper(new Media(), 1);
|
const wrapper = new HeaderWrapper(new Media(), 1);
|
||||||
const spy = sinon.spy(file.Header, "addTable");
|
const spy = sinon.spy(wrapper.Header, "addTable");
|
||||||
file.addTable(new Table(1, 1));
|
wrapper.addTable(new Table(1, 1));
|
||||||
|
|
||||||
expect(spy.called).to.equal(true);
|
expect(spy.called).to.equal(true);
|
||||||
});
|
});
|
||||||
|
@ -233,6 +233,7 @@ export class ImportDotx {
|
|||||||
private titlePageIsDefined(xmlData: string): boolean {
|
private titlePageIsDefined(xmlData: string): boolean {
|
||||||
const xmlObj = xml2js(xmlData, { compact: true }) as XMLElementCompact;
|
const xmlObj = xml2js(xmlData, { compact: true }) as XMLElementCompact;
|
||||||
const sectionProp = xmlObj["w:document"]["w:body"]["w:sectPr"];
|
const sectionProp = xmlObj["w:document"]["w:body"]["w:sectPr"];
|
||||||
|
|
||||||
return sectionProp["w:titlePg"] !== undefined;
|
return sectionProp["w:titlePg"] !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user