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

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-06-05 00:33:43 +01:00
import { describe, expect, it } from "vitest";
2023-02-04 23:50:37 +00:00
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", () => {
2023-02-04 23:53:37 +00:00
const element = new BuilderElement<{ readonly testAttr: string }>({
2023-02-04 23:50:37 +00:00
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",
},
},
});
});
});
});