Add tests for BuilderElement
This commit is contained in:
41
src/file/xml-components/simple-elements.spec.ts
Normal file
41
src/file/xml-components/simple-elements.spec.ts
Normal file
@ -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",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -92,5 +92,7 @@ export class BuilderElement<T extends AttributeData> extends XmlComponent {
|
||||
if (options.attributes) {
|
||||
this.root.push(new NextAttributeComponent(options.attributes));
|
||||
}
|
||||
|
||||
// TODO: Children
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user