Breaking Change. Swap arguments around and make default WidthType

This commit is contained in:
Dolan Miu
2018-11-15 03:00:26 +00:00
parent 28556f277b
commit e19890e27a
7 changed files with 50 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { BorderStyle } from "file/styles";
import { VerticalAlign, VMergeType, WidthType } from "./table-cell-components";
import { TableCellProperties } from "./table-cell-properties";
@ -42,12 +43,19 @@ describe("TableCellProperties", () => {
});
describe("#setWidth", () => {
it("sets width", () => {
it("should set width", () => {
const cellMargain = new TableCellProperties();
cellMargain.setWidth(1, WidthType.DXA);
const tree = new Formatter().format(cellMargain);
expect(tree).to.deep.equal({ "w:tcPr": [{ "w:tcW": [{ _attr: { "w:type": "dxa", "w:w": 1 } }] }] });
});
it("should set width using default of AUTO", () => {
const cellMargain = new TableCellProperties();
cellMargain.setWidth(1);
const tree = new Formatter().format(cellMargain);
expect(tree).to.deep.equal({ "w:tcPr": [{ "w:tcW": [{ _attr: { "w:type": "auto", "w:w": 1 } }] }] });
});
});
describe("#setShading", () => {
@ -61,4 +69,18 @@ describe("TableCellProperties", () => {
expect(tree).to.deep.equal({ "w:tcPr": [{ "w:shd": [{ _attr: { "w:fill": "test", "w:color": "000" } }] }] });
});
});
describe("#Borders", () => {
it("should return the TableCellBorders if Border has borders", () => {
const cellMargain = new TableCellProperties();
cellMargain.Borders.addTopBorder(BorderStyle.DASH_DOT_STROKED, 3, "red");
const borders = cellMargain.Borders;
const tree = new Formatter().format(borders);
expect(tree).to.deep.equal({
"w:tcBorders": [{ "w:top": [{ _attr: { "w:val": "dashDotStroked", "w:sz": 3, "w:color": "red" } }] }],
});
});
});
});