Turn back on no-null-keyword. Use empty object instead of null to signal to the xml library that an empty element should be produced. Update the related tests.

Related to #306
This commit is contained in:
Bruce Duncan
2019-04-10 01:28:37 -04:00
parent 816cb54b14
commit bb1604cd8f
17 changed files with 72 additions and 71 deletions

View File

@ -17,7 +17,7 @@ describe("GridCol", () => {
it("does not set a width attribute if not given", () => {
const grid = new GridCol();
const tree = new Formatter().format(grid);
expect(tree).to.deep.equal({ "w:gridCol": null });
expect(tree).to.deep.equal({ "w:gridCol": {} });
});
});
});

View File

@ -37,15 +37,15 @@ describe("TableColumn", () => {
const tree = new Formatter().format(cells[0]);
expect(tree).to.deep.equal({
"w:tc": [{ "w:tcPr": [{ "w:vMerge": { _attr: { "w:val": "restart" } } }] }, { "w:p": null }],
"w:tc": [{ "w:tcPr": [{ "w:vMerge": { _attr: { "w:val": "restart" } } }] }, { "w:p": {} }],
});
const tree2 = new Formatter().format(cells[1]);
expect(tree2).to.deep.equal({ "w:tc": [{ "w:p": null }] });
expect(tree2).to.deep.equal({ "w:tc": [{ "w:p": {} }] });
const tree3 = new Formatter().format(cells[2]);
expect(tree3).to.deep.equal({
"w:tc": [{ "w:tcPr": [{ "w:vMerge": { _attr: { "w:val": "continue" } } }] }, { "w:p": null }],
"w:tc": [{ "w:tcPr": [{ "w:vMerge": { _attr: { "w:val": "continue" } } }] }, { "w:p": {} }],
});
});
});

View File

@ -11,7 +11,7 @@ describe("TableRow", () => {
const tableRow = new TableRow([]);
const tree = new Formatter().format(tableRow);
expect(tree).to.deep.equal({
"w:tr": null,
"w:tr": {},
});
});
@ -23,7 +23,7 @@ describe("TableRow", () => {
{
"w:tc": [
{
"w:p": null,
"w:p": {},
},
],
},

View File

@ -107,7 +107,7 @@ const WIDTHS = {
// ],
// },
// { "w:tblGrid": [{ "w:gridCol": { _attr: { "w:w": 100 } } }] },
// { "w:tr": [{ "w:tc": [{ "w:p": null }] }] },
// { "w:tr": [{ "w:tc": [{ "w:p": {} }] }] },
// ],
// };
@ -119,7 +119,7 @@ describe("Table", () => {
columns: 2,
});
const tree = new Formatter().format(table);
const cell = { "w:tc": [{ "w:p": null }] };
const cell = { "w:tc": [{ "w:p": {} }] };
expect(tree).to.deep.equal({
"w:tbl": [
{ "w:tblPr": [DEFAULT_TABLE_PROPERTIES, BORDERS, WIDTHS] },
@ -284,7 +284,7 @@ describe("Table", () => {
.to.be.an("array")
.which.has.length.at.least(1);
expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({
"w:tc": [{ "w:p": null }],
"w:tc": [{ "w:p": {} }],
});
});
@ -311,7 +311,7 @@ describe("Table", () => {
const cell = row["w:tr"].find((x) => x["w:tc"]);
expect(cell).not.to.be.undefined;
expect(cell["w:tc"][cell["w:tc"].length - 1]).to.deep.equal({
"w:p": null,
"w:p": {},
});
});