Improve tests
This commit is contained in:
2
.nycrc
2
.nycrc
@ -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"
|
||||
|
@ -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: {
|
||||
|
@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user