Change table methods and document it

This commit is contained in:
Dolan Miu
2018-12-29 01:57:20 +00:00
parent 3b6aca2451
commit ab07f2ecbe
12 changed files with 185 additions and 38 deletions

View File

@ -111,19 +111,19 @@ describe("Table", () => {
table
.getRow(0)
.getCell(0)
.addContent(new Paragraph("A1"));
.addParagraph(new Paragraph("A1"));
table
.getRow(0)
.getCell(1)
.addContent(new Paragraph("B1"));
.addParagraph(new Paragraph("B1"));
table
.getRow(1)
.getCell(0)
.addContent(new Paragraph("A2"));
.addParagraph(new Paragraph("A2"));
table
.getRow(1)
.getCell(1)
.addContent(new Paragraph("B2"));
.addParagraph(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@ -149,10 +149,10 @@ describe("Table", () => {
describe("#getCell", () => {
it("returns the correct cell", () => {
const table = new Table(2, 2);
table.getCell(0, 0).addContent(new Paragraph("A1"));
table.getCell(0, 1).addContent(new Paragraph("B1"));
table.getCell(1, 0).addContent(new Paragraph("A2"));
table.getCell(1, 1).addContent(new Paragraph("B2"));
table.getCell(0, 0).addParagraph(new Paragraph("A1"));
table.getCell(0, 1).addParagraph(new Paragraph("B1"));
table.getCell(1, 0).addParagraph(new Paragraph("A2"));
table.getCell(1, 1).addParagraph(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@ -232,7 +232,7 @@ describe("Table", () => {
it("inserts a paragraph at the end of the cell even if it has a child table", () => {
const parentTable = new Table(1, 1);
parentTable.getCell(0, 0).addContent(new Table(1, 1));
parentTable.getCell(0, 0).addTable(new Table(1, 1));
const tree = new Formatter().format(parentTable);
expect(tree)
.to.have.property("w:tbl")
@ -251,7 +251,7 @@ describe("Table", () => {
it("does not insert a paragraph if it already ends with one", () => {
const parentTable = new Table(1, 1);
parentTable.getCell(0, 0).addContent(new Paragraph("Hello"));
parentTable.getCell(0, 0).addParagraph(new Paragraph("Hello"));
const tree = new Formatter().format(parentTable);
expect(tree)
.to.have.property("w:tbl")