diff --git a/src/file/xml-components/simple-elements.spec.ts b/src/file/xml-components/simple-elements.spec.ts new file mode 100644 index 0000000000..e87f8a4937 --- /dev/null +++ b/src/file/xml-components/simple-elements.spec.ts @@ -0,0 +1,41 @@ +import { expect } from "chai"; + +import { Formatter } from "@export/formatter"; + +import { BuilderElement } from "./simple-elements"; + +describe("BuilderElement", () => { + describe.only("#constructor()", () => { + 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", + }, + }, + }); + }); + }); +}); diff --git a/src/file/xml-components/simple-elements.ts b/src/file/xml-components/simple-elements.ts index 6ed117b7ba..dab6f618bc 100644 --- a/src/file/xml-components/simple-elements.ts +++ b/src/file/xml-components/simple-elements.ts @@ -92,5 +92,7 @@ export class BuilderElement extends XmlComponent { if (options.attributes) { this.root.push(new NextAttributeComponent(options.attributes)); } + + // TODO: Children } }