Improve tests
This commit is contained in:
2
.nycrc
2
.nycrc
@ -2,7 +2,7 @@
|
|||||||
"check-coverage": true,
|
"check-coverage": true,
|
||||||
"lines": 98.19,
|
"lines": 98.19,
|
||||||
"functions": 94.79,
|
"functions": 94.79,
|
||||||
"branches": 95.23,
|
"branches": 95.35,
|
||||||
"statements": 98.17,
|
"statements": 98.17,
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts"
|
"src/**/*.ts"
|
||||||
|
@ -24,6 +24,18 @@ describe("PageBorders", () => {
|
|||||||
expect(tree["w:pgBorders"]).to.deep.equal({ _attr: { "w:display": "firstPage" } });
|
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", () => {
|
it("should create page borders with full configuration", () => {
|
||||||
const properties = new PageBorders({
|
const properties = new PageBorders({
|
||||||
pageBorders: {
|
pageBorders: {
|
||||||
|
@ -72,18 +72,18 @@ export class PageBorders extends IgnoreIfEmptyXmlComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pageBordersAttributes = {};
|
|
||||||
|
|
||||||
if (options.pageBorders) {
|
if (options.pageBorders) {
|
||||||
pageBordersAttributes = {
|
this.root.push(
|
||||||
|
new PageBordersAttributes({
|
||||||
display: options.pageBorders.display,
|
display: options.pageBorders.display,
|
||||||
offsetFrom: options.pageBorders.offsetFrom,
|
offsetFrom: options.pageBorders.offsetFrom,
|
||||||
zOrder: options.pageBorders.zOrder,
|
zOrder: options.pageBorders.zOrder,
|
||||||
};
|
}),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.root.push(new PageBordersAttributes({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.root.push(new PageBordersAttributes(pageBordersAttributes));
|
|
||||||
|
|
||||||
if (options.pageBorderTop) {
|
if (options.pageBorderTop) {
|
||||||
this.root.push(new PageBorder("w:top", options.pageBorderTop));
|
this.root.push(new PageBorder("w:top", options.pageBorderTop));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user