Improve tests

This commit is contained in:
Dolan
2021-03-13 19:53:36 +00:00
parent 8aa804db18
commit cc9a966f53
3 changed files with 22 additions and 10 deletions

2
.nycrc
View File

@ -2,7 +2,7 @@
"check-coverage": true,
"lines": 98.19,
"functions": 94.79,
"branches": 95.23,
"branches": 95.35,
"statements": 98.17,
"include": [
"src/**/*.ts"

View File

@ -24,6 +24,18 @@ describe("PageBorders", () => {
expect(tree["w:pgBorders"]).to.deep.equal({ _attr: { "w:display": "firstPage" } });
});
it("should create page borders with default configuration", () => {
const properties = new PageBorders({});
const tree = new Formatter().format(properties);
expect(Object.keys(tree)).to.deep.equal(["w:pgBorders"]);
expect(tree).to.deep.equal({
"w:pgBorders": {
_attr: {},
},
});
});
it("should create page borders with full configuration", () => {
const properties = new PageBorders({
pageBorders: {

View File

@ -72,18 +72,18 @@ export class PageBorders extends IgnoreIfEmptyXmlComponent {
return;
}
let pageBordersAttributes = {};
if (options.pageBorders) {
pageBordersAttributes = {
display: options.pageBorders.display,
offsetFrom: options.pageBorders.offsetFrom,
zOrder: options.pageBorders.zOrder,
};
this.root.push(
new PageBordersAttributes({
display: options.pageBorders.display,
offsetFrom: options.pageBorders.offsetFrom,
zOrder: options.pageBorders.zOrder,
}),
);
} else {
this.root.push(new PageBordersAttributes({}));
}
this.root.push(new PageBordersAttributes(pageBordersAttributes));
if (options.pageBorderTop) {
this.root.push(new PageBorder("w:top", options.pageBorderTop));
}