Add table cell margin

This commit is contained in:
Dolan
2018-08-23 00:55:33 +01:00
parent 85f686dede
commit 877dcb462f
3 changed files with 82 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import { expect } from "chai";
import { Formatter } from "../../export/formatter";
import { TableProperties } from "./properties";
import { WidthType } from "./table-cell";
describe("TableProperties", () => {
describe("#constructor", () => {
@ -14,7 +15,7 @@ describe("TableProperties", () => {
describe("#setWidth", () => {
it("adds a table width property", () => {
const tp = new TableProperties().setWidth("dxa", 1234);
const tp = new TableProperties().setWidth(WidthType.DXA, 1234);
const tree = new Formatter().format(tp);
expect(tree).to.deep.equal({
"w:tblPr": [{ "w:tblW": [{ _attr: { "w:type": "dxa", "w:w": 1234 } }] }],
@ -31,4 +32,15 @@ describe("TableProperties", () => {
});
});
});
describe("#cellMargin", () => {
it("adds a table cell top margin", () => {
const tp = new TableProperties();
tp.CellMargin.addTopMargin(1234, WidthType.DXA);
const tree = new Formatter().format(tp);
expect(tree).to.deep.equal({
"w:tblPr": [{ "w:tblCellMar": [{ "w:top": [{ _attr: { "w:sz": "dxa", "w:w": 1234 } }] }] }],
});
});
});
});