Refactor to separate classes in their specific files an tests improuvements for styles

This commit is contained in:
Sergio Mendonça
2018-11-13 11:04:03 -02:00
parent ff443aa7c4
commit 7639b60b15
13 changed files with 1689 additions and 874 deletions

View File

@ -0,0 +1,36 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { Style } from "./style";
describe("Style", () => {
describe("#constructor()", () => {
it("should set the given properties", () => {
const style = new Style({
type: "paragraph",
styleId: "myStyleId",
default: true,
});
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } }],
});
});
it("should set the name of the style, if given", () => {
const style = new Style(
{
type: "paragraph",
styleId: "myStyleId",
},
"Style Name",
);
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
],
});
});
});
});