Files
docx-js/src/file/xml-components/xml-component.spec.ts
2019-06-26 02:11:43 +01:00

40 lines
1.0 KiB
TypeScript

import { expect } from "chai";
import { Formatter } from "export/formatter";
import { EMPTY_OBJECT, XmlComponent } from "./";
class TestComponent extends XmlComponent {}
describe("XmlComponent", () => {
let xmlComponent: TestComponent;
beforeEach(() => {
xmlComponent = new TestComponent("w:test");
});
describe("#constructor()", () => {
it("should create an Xml Component which has the correct rootKey", () => {
const tree = new Formatter().format(xmlComponent);
expect(tree).to.deep.equal({
"w:test": {},
});
});
});
describe("#prepForXml()", () => {
it("should skip deleted elements", () => {
const child = new TestComponent("w:test1");
child.delete();
xmlComponent.addChildElement(child);
const xml = xmlComponent.prepForXml();
if (!xml) {
return;
}
expect(xml["w:test"]).to.deep.equal(EMPTY_OBJECT);
});
});
});