2019-04-10 01:28:37 -04:00
|
|
|
import { expect } from "chai";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
2019-06-26 02:11:43 +01:00
|
|
|
import { Formatter } from "export/formatter";
|
2019-04-10 13:47:38 -04:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|
2018-04-26 14:16:02 +02: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
|
|
|
|
2018-04-26 14:16:02 +02:00
|
|
|
const xml = xmlComponent.prepForXml();
|
2018-09-20 00:41:57 +01:00
|
|
|
|
|
|
|
if (!xml) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-10 13:47:38 -04:00
|
|
|
expect(xml["w:test"]).to.deep.equal(EMPTY_OBJECT);
|
2018-04-26 14:16:02 +02:00
|
|
|
});
|
|
|
|
});
|
2017-03-09 20:49:14 +01:00
|
|
|
});
|