Improve tests

This commit is contained in:
fmuscolino
2019-06-25 14:48:45 +02:00
parent 2d4412ce51
commit b08354494c
2 changed files with 29 additions and 11 deletions

View File

@ -34,25 +34,19 @@ describe("TableRowProperties", () => {
}); });
describe("#setHeight", () => { describe("#setHeight", () => {
it("sets exact row height", () => { it("sets row height exact", () => {
const rowProperties = new TableRowProperties(); const rowProperties = new TableRowProperties();
rowProperties.setHeight(100, HeightRule.EXACT); rowProperties.setHeight(100, HeightRule.EXACT);
const tree = new Formatter().format(rowProperties); const tree = new Formatter().format(rowProperties);
expect(tree).to.deep.equal({ "w:trPr": [{ "w:trHeight": { _attr: { "w:val": 100, "w:hRule": "exact" } } }] }); expect(tree).to.deep.equal({ "w:trPr": [{ "w:trHeight": { _attr: { "w:val": 100, "w:hRule": "exact" } } }] });
}); });
}); it("sets row height auto", () => {
describe("#setHeight", () => {
it("sets auto row height", () => {
const rowProperties = new TableRowProperties(); const rowProperties = new TableRowProperties();
rowProperties.setHeight(100, HeightRule.AUTO); rowProperties.setHeight(100, HeightRule.AUTO);
const tree = new Formatter().format(rowProperties); const tree = new Formatter().format(rowProperties);
expect(tree).to.deep.equal({ "w:trPr": [{ "w:trHeight": { _attr: { "w:val": 100, "w:hRule": "auto" } } }] }); expect(tree).to.deep.equal({ "w:trPr": [{ "w:trHeight": { _attr: { "w:val": 100, "w:hRule": "auto" } } }] });
}); });
}); it("sets row height at least", () => {
describe("#setHeight", () => {
it("sets at least row height", () => {
const rowProperties = new TableRowProperties(); const rowProperties = new TableRowProperties();
rowProperties.setHeight(100, HeightRule.ATLEAST); rowProperties.setHeight(100, HeightRule.ATLEAST);
const tree = new Formatter().format(rowProperties); const tree = new Formatter().format(rowProperties);

View File

@ -2,11 +2,11 @@ import { expect } from "chai";
import { Formatter } from "export/formatter"; import { Formatter } from "export/formatter";
import { HeightRule } from "file/table/table-row/table-row-height";
import { EMPTY_OBJECT } from "file/xml-components";
import { TableCell } from "../table-cell"; import { TableCell } from "../table-cell";
import { TableRow } from "./table-row"; import { TableRow } from "./table-row";
import { EMPTY_OBJECT } from "file/xml-components";
describe("TableRow", () => { describe("TableRow", () => {
describe("#constructor", () => { describe("#constructor", () => {
it("should create with no cells", () => { it("should create with no cells", () => {
@ -67,4 +67,28 @@ describe("TableRow", () => {
expect(() => tableRow.getCell(1)).to.throw(); expect(() => tableRow.getCell(1)).to.throw();
}); });
}); });
describe("#setHeight", () => {
it("should set row height", () => {
const tableRow = new TableRow([]);
tableRow.setHeight(100, HeightRule.EXACT);
const tree = new Formatter().format(tableRow);
expect(tree).to.deep.equal({
"w:tr": [
{
"w:trPr": [
{
"w:trHeight": {
_attr: {
"w:hRule": "exact",
"w:val": 100,
},
},
},
],
},
],
});
});
});
}); });