diff --git a/.nycrc b/.nycrc index 2d0c37e9f9..87728e5edb 100644 --- a/.nycrc +++ b/.nycrc @@ -1,9 +1,9 @@ { "check-coverage": true, - "statements": 99.62, - "branches": 96.81, + "statements": 99.72, + "branches": 97.95, "functions": 99.82, - "lines": 99.62, + "lines": 99.71, "include": [ "src/**/*.ts" ], diff --git a/src/file/document/body/section-properties/properties/columns.spec.ts b/src/file/document/body/section-properties/properties/columns.spec.ts index c301d4efeb..8f0bcdd655 100644 --- a/src/file/document/body/section-properties/properties/columns.spec.ts +++ b/src/file/document/body/section-properties/properties/columns.spec.ts @@ -13,6 +13,13 @@ describe("Columns", () => { expect(tree["w:cols"]).to.deep.equal({ _attr: { "w:num": 3, "w:space": 720 } }); }); + it("should create set space and count to undefined if they are undefined", () => { + const columns = new Columns({}); + const tree = new Formatter().format(columns); + + expect(tree["w:cols"]).to.deep.equal({ _attr: {} }); + }); + it("should ignore individual column attributes if equalWidth is true", () => { const unequalColumns = [new Column({ width: 1000, space: 400 }), new Column({ width: 2000 })]; const columns = new Columns({ count: 3, space: 720, equalWidth: true, children: unequalColumns }); diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts index b0d9278b18..bc9f554af6 100644 --- a/src/file/file.spec.ts +++ b/src/file/file.spec.ts @@ -6,6 +6,7 @@ import { sectionMarginDefaults, sectionPageSizeDefaults } from "./document"; import { File } from "./file"; import { Footer, Header } from "./header"; import { Paragraph } from "./paragraph"; +import { Media } from "./media"; const PAGE_SIZE_DEFAULTS = { "w:h": sectionPageSizeDefaults.HEIGHT, @@ -411,4 +412,58 @@ describe("File", () => { expect(doc.Numbering).to.not.be.undefined; }); }); + + describe("#getters", () => { + it("should have defined getters", () => { + const doc = new File({ + sections: [], + }); + + expect(doc.CoreProperties).to.not.be.undefined; + expect(doc.Media).to.not.be.undefined; + expect(doc.FileRelationships).to.not.be.undefined; + expect(doc.Headers).to.not.be.undefined; + expect(doc.Footers).to.not.be.undefined; + expect(doc.ContentTypes).to.not.be.undefined; + expect(doc.CustomProperties).to.not.be.undefined; + expect(doc.AppProperties).to.not.be.undefined; + expect(doc.FootNotes).to.not.be.undefined; + expect(doc.Settings).to.not.be.undefined; + expect(doc.Comments).to.not.be.undefined; + }); + }); + + describe("#templates", () => { + // Test will be deprecated when import-dotx and templates are deprecated + it("should work with template", () => { + const doc = new File( + { + sections: [], + }, + { + template: { + currentRelationshipId: 1, + headers: [], + footers: [], + styles: "", + titlePageIsDefined: true, + media: new Media(), + }, + }, + ); + + expect(doc).to.not.be.undefined; + }); + }); + + describe("#externalStyles", () => { + it("should work with external styles", () => { + const doc = new File({ + sections: [], + externalStyles: "", + }); + + expect(doc.Styles).to.not.be.undefined; + }); + }); });