2018-11-13 11:04:03 -02:00
|
|
|
import { expect } from "chai";
|
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
import { Style } from "./style";
|
|
|
|
|
|
|
|
describe("Style", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should set the given properties", () => {
|
2021-05-25 04:27:10 +03:00
|
|
|
const style = new Style(
|
|
|
|
{
|
|
|
|
type: "paragraph",
|
|
|
|
styleId: "myStyleId",
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
);
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:style": { _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } },
|
2018-11-13 11:04:03 -02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should set the name of the style, if given", () => {
|
|
|
|
const style = new Style(
|
|
|
|
{
|
|
|
|
type: "paragraph",
|
|
|
|
styleId: "myStyleId",
|
|
|
|
},
|
2021-05-25 04:27:10 +03:00
|
|
|
{ name: "Style Name" },
|
2018-11-13 11:04:03 -02:00
|
|
|
);
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
2019-04-09 05:27:18 -04:00
|
|
|
{ "w:name": { _attr: { "w:val": "Style Name" } } },
|
2018-11-13 11:04:03 -02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|