Remove create table helper function

This commit is contained in:
Dolan
2019-06-25 01:21:28 +01:00
parent dfe986331d
commit c97d15cb9f
22 changed files with 132 additions and 422 deletions

View File

@ -2,7 +2,6 @@ import { assert, expect } from "chai";
import { Formatter } from "export/formatter";
import { Table } from "../table";
import { Document } from "./document";
describe("Document", () => {
@ -29,40 +28,4 @@ describe("Document", () => {
expect(body[0]).to.have.property("w:sectPr");
});
});
describe("#createTable", () => {
it("should create a new table and append it to body", () => {
const table = document.createTable({
rows: 2,
columns: 3,
});
expect(table).to.be.an.instanceof(Table);
const body = new Formatter().format(document)["w:document"][1]["w:body"];
expect(body)
.to.be.an("array")
.which.has.length.at.least(1);
expect(body[0]).to.have.property("w:tbl");
});
it("should create a table with the correct dimensions", () => {
document.createTable({
rows: 2,
columns: 3,
});
const body = new Formatter().format(document)["w:document"][1]["w:body"];
expect(body)
.to.be.an("array")
.which.has.length.at.least(1);
expect(body[0])
.to.have.property("w:tbl")
.which.includes({
"w:tblGrid": [
{ "w:gridCol": { _attr: { "w:w": 100 } } },
{ "w:gridCol": { _attr: { "w:w": 100 } } },
{ "w:gridCol": { _attr: { "w:w": 100 } } },
],
});
expect(body[0]["w:tbl"].filter((x) => x["w:tr"])).to.have.length(2);
});
});
});