remove more duplicate classes; add additional values functions; clean up tests

This commit is contained in:
Tom Hunkapiller
2021-05-24 11:28:10 +03:00
parent a56119e7cd
commit ce2a0fb864
38 changed files with 311 additions and 362 deletions

View File

@ -1,15 +0,0 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { Bidirectional } from "./bidirectional";
describe("Bidirectional", () => {
it("should create", () => {
const bidirectional = new Bidirectional();
const tree = new Formatter().format(bidirectional);
expect(tree).to.deep.equal({
"w:bidi": {},
});
});
});

View File

@ -1,7 +0,0 @@
import { XmlComponent } from "file/xml-components";
export class Bidirectional extends XmlComponent {
constructor() {
super("w:bidi");
}
}

View File

@ -1,7 +1,6 @@
export * from "./alignment";
export * from "./border";
export * from "./indent";
export * from "./keep";
export * from "./page-break";
export * from "./spacing";
export * from "./style";

View File

@ -1,13 +0,0 @@
import { XmlComponent } from "file/xml-components";
export class KeepLines extends XmlComponent {
constructor() {
super("w:keepLines");
}
}
export class KeepNext extends XmlComponent {
constructor() {
super("w:keepNext");
}
}

View File

@ -2,7 +2,7 @@ import { expect } from "chai";
import { Formatter } from "export/formatter";
import { ContextualSpacing, Spacing } from "./spacing";
import { Spacing } from "./spacing";
describe("Spacing", () => {
describe("#constructor", () => {
@ -23,23 +23,3 @@ describe("Spacing", () => {
});
});
});
describe("ContextualSpacing", () => {
describe("#constructor", () => {
it("should create", () => {
const spacing = new ContextualSpacing(true);
const tree = new Formatter().format(spacing);
expect(tree).to.deep.equal({
"w:contextualSpacing": { _attr: { "w:val": 1 } },
});
});
it("should create with value of 0 if param is false", () => {
const spacing = new ContextualSpacing(false);
const tree = new Formatter().format(spacing);
expect(tree).to.deep.equal({
"w:contextualSpacing": { _attr: { "w:val": 0 } },
});
});
});
});

View File

@ -1,5 +1,5 @@
// http://officeopenxml.com/WPspacing.php
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
export enum LineRuleType {
AT_LEAST = "atLeast",
@ -30,14 +30,3 @@ export class Spacing extends XmlComponent {
this.root.push(new SpacingAttributes(options));
}
}
export class ContextualSpacing extends XmlComponent {
constructor(value: boolean) {
super("w:contextualSpacing");
this.root.push(
new Attributes({
val: value === false ? 0 : 1,
}),
);
}
}

View File

@ -1,20 +0,0 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { WidowControl } from "./widow-control";
describe("WidowControl", () => {
it("should create", () => {
const widowControl = new WidowControl(true);
const tree = new Formatter().format(widowControl);
expect(tree).to.deep.equal({
"w:widowControl": {
_attr: {
"w:val": true,
},
},
});
});
});

View File

@ -1,13 +0,0 @@
// http://www.datypic.com/sc/ooxml/e-w_widowControl-1.html
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
export class WidowControlAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class WidowControl extends XmlComponent {
constructor(value: boolean) {
super("w:widowControl");
this.root.push(new WidowControlAttributes({ val: value }));
}
}