Simplify run format properties, removing duplicate classes. Add values functions, which check and clean up values for specific defined types from the schema

This commit is contained in:
Tom Hunkapiller
2021-05-24 08:20:08 +03:00
parent 449e1ed963
commit ee105cdb83
13 changed files with 274 additions and 265 deletions

View File

@ -2,18 +2,35 @@ import { expect } from "chai";
import { Formatter } from "export/formatter";
import { Bold } from "./formatting";
import { CharacterSpacing, Color } from "./formatting";
describe("Bold", () => {
describe("CharacterSpacing", () => {
describe("#constructor()", () => {
it("should create", () => {
const currentBold = new Bold();
const element = new CharacterSpacing(32);
const tree = new Formatter().format(currentBold);
const tree = new Formatter().format(element);
expect(tree).to.deep.equal({
"w:b": {
"w:spacing": {
_attr: {
"w:val": true,
"w:val": 32,
},
},
});
});
});
});
describe("Color", () => {
describe("#constructor()", () => {
it("should create", () => {
const element = new Color("#FFFFFF");
const tree = new Formatter().format(element);
expect(tree).to.deep.equal({
"w:color": {
_attr: {
"w:val": "FFFFFF",
},
},
});