2016-07-17 16:03:31 +01:00
|
|
|
import {XmlComponent} from "../../../docx/xml-components";
|
|
|
|
import {assert} from "chai";
|
|
|
|
|
|
|
|
function jsonify(obj: Object) {
|
|
|
|
let stringifiedJson = JSON.stringify(obj);
|
|
|
|
return JSON.parse(stringifiedJson);
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestComponent extends XmlComponent {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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", () => {
|
|
|
|
let newJson = jsonify(xmlComponent);
|
|
|
|
assert.equal(newJson.rootKey, "w:test");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#replaceKey", () => {
|
|
|
|
|
|
|
|
it("should replace the key to the specified root key", () => {
|
|
|
|
xmlComponent.replaceKey();
|
|
|
|
let newJson = jsonify(xmlComponent);
|
|
|
|
assert.isDefined(newJson["w:test"]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|