Add tests and clean up code
This commit is contained in:
@ -8,7 +8,7 @@ import { Table } from "./table";
|
||||
// import { WidthType } from "./table-cell";
|
||||
import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType } from "./table-properties";
|
||||
|
||||
import { TableCell } from "./table-cell";
|
||||
import { TableCell, WidthType } from "./table-cell";
|
||||
import { TableLayoutType } from "./table-properties/table-layout";
|
||||
import { TableRow } from "./table-row";
|
||||
|
||||
@ -210,6 +210,45 @@ describe("Table", () => {
|
||||
"w:tblPr": [DEFAULT_TABLE_PROPERTIES, BORDERS, WIDTHS, { "w:tblLayout": { _attr: { "w:type": "fixed" } } }],
|
||||
});
|
||||
});
|
||||
|
||||
it("should set the table to provided width", () => {
|
||||
const table = new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("hello")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
width: {
|
||||
size: 100,
|
||||
type: WidthType.PERCENTAGE,
|
||||
},
|
||||
layout: TableLayoutType.FIXED,
|
||||
});
|
||||
const tree = new Formatter().format(table);
|
||||
expect(tree)
|
||||
.to.have.property("w:tbl")
|
||||
.which.is.an("array")
|
||||
.with.has.length.at.least(1);
|
||||
expect(tree["w:tbl"][0]).to.deep.equal({
|
||||
"w:tblPr": [
|
||||
DEFAULT_TABLE_PROPERTIES,
|
||||
BORDERS,
|
||||
{
|
||||
"w:tblW": {
|
||||
_attr: {
|
||||
"w:type": "pct",
|
||||
"w:w": "100%",
|
||||
},
|
||||
},
|
||||
},
|
||||
{ "w:tblLayout": { _attr: { "w:type": "fixed" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Cell", () => {
|
||||
|
Reference in New Issue
Block a user