added new tests for xml components

This commit is contained in:
Dolan Miu
2016-07-17 16:03:31 +01:00
parent f8cf0431c0
commit 016cffd66c
2 changed files with 37 additions and 1 deletions

View File

@ -34,7 +34,7 @@ describe("RightTabStop", () => {
});
describe.only("MaxRightTabStop", () => {
describe("MaxRightTabStop", () => {
let tabStop: MaxRightTabStop;
beforeEach(() => {

View File

@ -0,0 +1,36 @@
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 {
}
describe.only("XmlComponent", () => {
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"]);
});
});
});