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

40 lines
1.0 KiB
TypeScript
Raw Normal View History

import { expect } from "chai";
2019-06-26 02:11:43 +01:00
import { Formatter } from "export/formatter";
import { EMPTY_OBJECT, XmlComponent } from "./";
2016-07-17 16:03:31 +01:00
2018-01-23 01:33:12 +00:00
class TestComponent extends XmlComponent {}
2016-07-17 16:03:31 +01:00
2016-07-17 16:18:20 +01:00
describe("XmlComponent", () => {
2016-07-17 16:03:31 +01:00
let xmlComponent: TestComponent;
beforeEach(() => {
xmlComponent = new TestComponent("w:test");
});
describe("#constructor()", () => {
it("should create an Xml Component which has the correct rootKey", () => {
2019-06-26 02:11:43 +01:00
const tree = new Formatter().format(xmlComponent);
expect(tree).to.deep.equal({
"w:test": {},
});
2016-07-17 16:03:31 +01:00
});
});
describe("#prepForXml()", () => {
it("should skip deleted elements", () => {
const child = new TestComponent("w:test1");
child.delete();
xmlComponent.addChildElement(child);
2018-05-06 03:19:36 +01:00
const xml = xmlComponent.prepForXml();
if (!xml) {
return;
}
expect(xml["w:test"]).to.deep.equal(EMPTY_OBJECT);
});
});
});