2017-03-10 17:38:04 +01:00
|
|
|
import { expect } from "chai";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
|
|
|
import { Formatter } from "../../export/formatter";
|
|
|
|
import { GridCol, TableGrid } from "./grid";
|
2017-03-10 17:38:04 +01:00
|
|
|
|
|
|
|
describe("GridCol", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("sets the width attribute to the value given", () => {
|
|
|
|
const grid = new GridCol(1234);
|
|
|
|
const tree = new Formatter().format(grid);
|
|
|
|
expect(tree).to.deep.equal({
|
2018-01-23 01:33:12 +00:00
|
|
|
"w:gridCol": [{ _attr: { "w:w": 1234 } }],
|
2017-03-10 17:38:04 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("does not set a width attribute if not given", () => {
|
|
|
|
const grid = new GridCol();
|
|
|
|
const tree = new Formatter().format(grid);
|
2018-01-23 01:33:12 +00:00
|
|
|
expect(tree).to.deep.equal({ "w:gridCol": [] });
|
2017-03-10 17:38:04 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("TableGrid", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("creates a column for each width given", () => {
|
|
|
|
const grid = new TableGrid([1234, 321, 123]);
|
|
|
|
const tree = new Formatter().format(grid);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:tblGrid": [
|
2018-01-23 01:33:12 +00:00
|
|
|
{ "w:gridCol": [{ _attr: { "w:w": 1234 } }] },
|
|
|
|
{ "w:gridCol": [{ _attr: { "w:w": 321 } }] },
|
|
|
|
{ "w:gridCol": [{ _attr: { "w:w": 123 } }] },
|
2017-03-10 17:38:04 +01:00
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|