Files
docx-js/src/file/xml-components/simple-elements.spec.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-02-04 23:50:37 +00:00
import { expect } from "chai";
import { Formatter } from "@export/formatter";
import { BuilderElement } from "./simple-elements";
describe("BuilderElement", () => {
2023-02-04 23:50:59 +00:00
describe("#constructor()", () => {
2023-02-04 23:50:37 +00:00
it("should create a simple BuilderElement", () => {
const element = new BuilderElement({
name: "test",
});
const tree = new Formatter().format(element);
expect(tree).to.deep.equal({
test: {},
});
});
it("should create a simple BuilderElement with attributes", () => {
const element = new BuilderElement<{ testAttr: string }>({
name: "test",
attributes: {
testAttr: {
key: "w:testAttr",
value: "test",
},
},
});
const tree = new Formatter().format(element);
expect(tree).to.deep.equal({
test: {
_attr: {
"w:testAttr": "test",
},
},
});
});
});
});