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

33 lines
919 B
TypeScript
Raw Normal View History

import { assert } from "chai";
import { Utility } from "../../tests/utility";
import { 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", () => {
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(xmlComponent);
2016-07-17 16:03:31 +01:00
assert.equal(newJson.rootKey, "w:test");
});
});
describe("#prepForXml()", () => {
it("should skip deleted elements", () => {
const child = new TestComponent("w:test1");
child.delete();
xmlComponent.addChildElement(child);
2018-05-17 15:32:15 +02:00
const xml = xmlComponent.prepForXml();
2018-05-17 15:32:15 +02:00
assert.equal(xml["w:test"].length, 0);
});
});
});