diff --git a/.nycrc b/.nycrc index d5f12ccbc3..1e3c3b1e22 100644 --- a/.nycrc +++ b/.nycrc @@ -1,9 +1,9 @@ { "check-coverage": true, - "lines": 92.35, - "functions": 88.28, + "lines": 92.34, + "functions": 88.27, "branches": 84.64, - "statements": 92.16, + "statements": 92.15, "include": [ "src/**/*.ts" ], diff --git a/src/file/document/body/body.spec.ts b/src/file/document/body/body.spec.ts index a5bc222fb4..b63a95dcd1 100644 --- a/src/file/document/body/body.spec.ts +++ b/src/file/document/body/body.spec.ts @@ -22,9 +22,6 @@ describe("Body", () => { expect(tree).to.deep.equal({ "w:body": [ - { - "w:p": {}, - }, { "w:sectPr": [ { "w:pgSz": { _attr: { "w:w": 10000, "w:h": 10000, "w:orient": "portrait" } } }, diff --git a/src/file/document/body/body.ts b/src/file/document/body/body.ts index e91b72d59a..c79edfc132 100644 --- a/src/file/document/body/body.ts +++ b/src/file/document/body/body.ts @@ -1,5 +1,5 @@ import { IXmlableObject, XmlComponent } from "file/xml-components"; -import { Paragraph, ParagraphProperties, TableOfContents } from "../.."; +import { TableOfContents } from "../.."; import { SectionProperties, SectionPropertiesOptions } from "./section-properties/section-properties"; export class Body extends XmlComponent { @@ -18,9 +18,6 @@ export class Body extends XmlComponent { * @param options new section options */ public addSection(options: SectionPropertiesOptions): void { - const currentSection = this.sections.pop() as SectionProperties; - this.root.push(this.createSectionParagraph(currentSection)); - this.sections.push(new SectionProperties(options)); } @@ -39,12 +36,4 @@ export class Body extends XmlComponent { public getTablesOfContents(): TableOfContents[] { return this.root.filter((child) => child instanceof TableOfContents) as TableOfContents[]; } - - private createSectionParagraph(section: SectionProperties): Paragraph { - const paragraph = new Paragraph({}); - const properties = new ParagraphProperties({}); - properties.addChildElement(section); - paragraph.addChildElement(properties); - return paragraph; - } } diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts index dae4af33fb..e8c081d1ec 100644 --- a/src/file/file.spec.ts +++ b/src/file/file.spec.ts @@ -20,8 +20,8 @@ describe("File", () => { const tree = new Formatter().format(doc.Document.Body); - expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); - expect(tree["w:body"][1]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default"); }); it("should create with correct headers and footers", () => { @@ -39,8 +39,8 @@ describe("File", () => { const tree = new Formatter().format(doc.Document.Body); - expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); - expect(tree["w:body"][1]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default"); }); it("should create with first headers and footers", () => { @@ -58,8 +58,8 @@ describe("File", () => { const tree = new Formatter().format(doc.Document.Body); - expect(tree["w:body"][1]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first"); - expect(tree["w:body"][1]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("first"); + expect(tree["w:body"][0]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first"); + expect(tree["w:body"][0]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("first"); }); it("should create with correct headers", () => { @@ -81,13 +81,13 @@ describe("File", () => { const tree = new Formatter().format(doc.Document.Body); - expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); - expect(tree["w:body"][1]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first"); - expect(tree["w:body"][1]["w:sectPr"][6]["w:headerReference"]._attr["w:type"]).to.equal("even"); + expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first"); + expect(tree["w:body"][0]["w:sectPr"][6]["w:headerReference"]._attr["w:type"]).to.equal("even"); - expect(tree["w:body"][1]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("default"); - expect(tree["w:body"][1]["w:sectPr"][8]["w:footerReference"]._attr["w:type"]).to.equal("first"); - expect(tree["w:body"][1]["w:sectPr"][9]["w:footerReference"]._attr["w:type"]).to.equal("even"); + expect(tree["w:body"][0]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("default"); + expect(tree["w:body"][0]["w:sectPr"][8]["w:footerReference"]._attr["w:type"]).to.equal("first"); + expect(tree["w:body"][0]["w:sectPr"][9]["w:footerReference"]._attr["w:type"]).to.equal("even"); }); });