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

@ -20,7 +20,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -41,7 +41,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -63,7 +63,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
{ "w:basedOn": { _attr: { "w:val": "otherId" } } },
],
@ -89,7 +89,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -113,7 +113,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -136,7 +136,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -159,7 +159,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -191,7 +191,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -214,7 +214,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -237,7 +237,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -260,7 +260,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -280,7 +280,7 @@ describe("CharacterStyle", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
{ "w:link": { _attr: { "w:val": "MyLink" } } },
],
@ -300,8 +300,8 @@ describe("CharacterStyle", () => {
},
},
},
{ "w:unhideWhenUsed": null },
{ "w:semiHidden": null },
{ "w:unhideWhenUsed": {} },
{ "w:semiHidden": {} },
],
});
});

View File

@ -36,18 +36,18 @@ describe("Style components", () => {
it("UnhideWhenUsed#constructor", () => {
const style = new components.UnhideWhenUsed();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({ "w:unhideWhenUsed": null });
expect(tree).to.deep.equal({ "w:unhideWhenUsed": {} });
});
it("QuickFormat#constructor", () => {
const style = new components.QuickFormat();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({ "w:qFormat": null });
expect(tree).to.deep.equal({ "w:qFormat": {} });
});
it("SemiHidden#constructor", () => {
const style = new components.SemiHidden();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({ "w:semiHidden": null });
expect(tree).to.deep.equal({ "w:semiHidden": {} });
});
});

View File

@ -12,7 +12,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 1" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -26,7 +26,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Title" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -40,7 +40,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 1" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -54,7 +54,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 2" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -68,7 +68,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 3" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -82,7 +82,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 4" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -96,7 +96,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 5" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -110,7 +110,7 @@ describe("Default Styles", () => {
{ "w:name": { _attr: { "w:val": "Heading 6" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:next": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -123,7 +123,7 @@ describe("Default Styles", () => {
{ _attr: { "w:type": "paragraph", "w:styleId": "ListParagraph" } },
{ "w:name": { _attr: { "w:val": "List Paragraph" } } },
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
{ "w:qFormat": null },
{ "w:qFormat": {} },
],
});
});
@ -176,10 +176,10 @@ describe("Default Styles", () => {
},
},
{
"w:semiHidden": null,
"w:semiHidden": {},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
});
@ -211,12 +211,12 @@ describe("Default Styles", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
{
"w:semiHidden": null,
"w:semiHidden": {},
},
],
});
@ -255,12 +255,12 @@ describe("Default Styles", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
{ "w:link": { _attr: { "w:val": "FootnoteText" } } },
{
"w:semiHidden": null,
"w:semiHidden": {},
},
],
});
@ -284,7 +284,7 @@ describe("Default Styles", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
],

View File

@ -42,7 +42,7 @@ describe("ParagraphStyle", () => {
const style = new ParagraphStyle("myStyleId").quickFormat();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:qFormat": null }],
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:qFormat": {} }],
});
});
@ -216,7 +216,7 @@ describe("ParagraphStyle", () => {
const style = new ParagraphStyle("myStyleId").keepLines();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepLines": null }] }],
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepLines": {} }] }],
});
});
@ -224,7 +224,7 @@ describe("ParagraphStyle", () => {
const style = new ParagraphStyle("myStyleId").keepNext();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepNext": null }] }],
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepNext": {} }] }],
});
});
@ -439,7 +439,7 @@ describe("ParagraphStyle", () => {
const style = new ParagraphStyle("myStyleId").semiHidden();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:semiHidden": null }],
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:semiHidden": {} }],
});
});
@ -464,7 +464,7 @@ describe("ParagraphStyle", () => {
const style = new ParagraphStyle("myStyleId").unhideWhenUsed();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:unhideWhenUsed": null }],
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:unhideWhenUsed": {} }],
});
});
});

View File

@ -64,7 +64,7 @@ describe("Styles", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
},
@ -88,7 +88,7 @@ describe("Styles", () => {
},
},
{
"w:unhideWhenUsed": null,
"w:unhideWhenUsed": {},
},
],
},