Consolidate TableWidth and TableCellMargins types; add Table indent (#954)
This commit is contained in:
@ -1,25 +1,23 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { WidthType } from "../table-width";
|
||||
|
||||
import { WidthType } from "../table-cell";
|
||||
import { TableCellMargin } from "./table-cell-margin";
|
||||
import { TableCellMargin, TableCellMarginElementType } from "./table-cell-margin";
|
||||
|
||||
describe("TableCellMargin", () => {
|
||||
describe("#constructor", () => {
|
||||
it("should throw an error if theres no child elements", () => {
|
||||
const cellMargin = new TableCellMargin({});
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {});
|
||||
expect(() => new Formatter().format(cellMargin)).to.throw();
|
||||
});
|
||||
});
|
||||
|
||||
describe("#addTopMargin", () => {
|
||||
it("should add a table cell top margin", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
top: {
|
||||
value: 1234,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
marginUnitType: WidthType.DXA,
|
||||
top: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
@ -27,10 +25,8 @@ describe("TableCellMargin", () => {
|
||||
});
|
||||
|
||||
it("should add a table cell top margin using default width type", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
top: {
|
||||
value: 1234,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
top: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
@ -40,21 +36,17 @@ describe("TableCellMargin", () => {
|
||||
|
||||
describe("#addLeftMargin", () => {
|
||||
it("should add a table cell left margin", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
left: {
|
||||
value: 1234,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
marginUnitType: WidthType.DXA,
|
||||
left: 1234,
|
||||
});
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
expect(tree).to.deep.equal({ "w:tblCellMar": [{ "w:left": { _attr: { "w:type": "dxa", "w:w": 1234 } } }] });
|
||||
});
|
||||
|
||||
it("should add a table cell left margin using default width type", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
left: {
|
||||
value: 1234,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
left: 1234,
|
||||
});
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
expect(tree).to.deep.equal({ "w:tblCellMar": [{ "w:left": { _attr: { "w:type": "dxa", "w:w": 1234 } } }] });
|
||||
@ -63,11 +55,9 @@ describe("TableCellMargin", () => {
|
||||
|
||||
describe("#addBottomMargin", () => {
|
||||
it("should add a table cell bottom margin", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
bottom: {
|
||||
value: 1234,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
marginUnitType: WidthType.DXA,
|
||||
bottom: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
@ -75,10 +65,8 @@ describe("TableCellMargin", () => {
|
||||
});
|
||||
|
||||
it("should add a table cell bottom margin using default width type", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
bottom: {
|
||||
value: 1234,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
bottom: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
@ -88,11 +76,9 @@ describe("TableCellMargin", () => {
|
||||
|
||||
describe("#addRightMargin", () => {
|
||||
it("should add a table cell right margin", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
right: {
|
||||
value: 1234,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
marginUnitType: WidthType.DXA,
|
||||
right: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
@ -100,10 +86,8 @@ describe("TableCellMargin", () => {
|
||||
});
|
||||
|
||||
it("should add a table cell right margin using default width type", () => {
|
||||
const cellMargin = new TableCellMargin({
|
||||
right: {
|
||||
value: 1234,
|
||||
},
|
||||
const cellMargin = new TableCellMargin(TableCellMarginElementType.TABLE, {
|
||||
right: 1234,
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(cellMargin);
|
||||
|
Reference in New Issue
Block a user