wrote lots of tests
This commit is contained in:
@ -5,7 +5,7 @@ abstract class VerticalAlign extends XmlComponent {
|
||||
constructor(type: string) {
|
||||
super("w:vertAlign");
|
||||
this.root.push(new Attributes({
|
||||
val: "superscript"
|
||||
val: type
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ describe("PageBreak", () => {
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Tab Stop with correct attributes", () => {
|
||||
it("should create a Page Break with correct attributes", () => {
|
||||
let newJson = jsonify(pageBreak);
|
||||
let attributes = {
|
||||
type: "page"
|
||||
|
@ -6,7 +6,7 @@ function jsonify(obj: Object) {
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
describe.only("Break", () => {
|
||||
describe("Break", () => {
|
||||
let currentBreak: Break;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -1,6 +1,3 @@
|
||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
||||
|
||||
import {Run} from "../../../docx/run";
|
||||
import {TextRun} from "../../../docx/run/text-run";
|
||||
import {assert} from "chai";
|
||||
|
53
ts/tests/docx/run/scriptTests.ts
Normal file
53
ts/tests/docx/run/scriptTests.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import {SubScript, SuperScript} from "../../../docx/run/script";
|
||||
import {assert} from "chai";
|
||||
|
||||
function jsonify(obj: Object) {
|
||||
let stringifiedJson = JSON.stringify(obj);
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
describe("SubScript", () => {
|
||||
let subScript: SubScript;
|
||||
|
||||
beforeEach(() => {
|
||||
subScript = new SubScript();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Sub Script with correct attributes", () => {
|
||||
let newJson = jsonify(subScript);
|
||||
let attributes = {
|
||||
val: "subscript"
|
||||
};
|
||||
assert.equal(JSON.stringify(newJson.root[0].root), JSON.stringify(attributes));
|
||||
});
|
||||
|
||||
it("should create a Sub Script with correct root key", () => {
|
||||
let newJson = jsonify(subScript);
|
||||
assert.equal(newJson.rootKey, "w:vertAlign");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("SuperScript", () => {
|
||||
let superScript: SuperScript;
|
||||
|
||||
beforeEach(() => {
|
||||
superScript = new SuperScript();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Super Script with correct attributes", () => {
|
||||
let newJson = jsonify(superScript);
|
||||
let attributes = {
|
||||
val: "superscript"
|
||||
};
|
||||
assert.equal(JSON.stringify(newJson.root[0].root), JSON.stringify(attributes));
|
||||
});
|
||||
|
||||
it("should create a Super Script with correct root key", () => {
|
||||
let newJson = jsonify(superScript);
|
||||
assert.equal(newJson.rootKey, "w:vertAlign");
|
||||
});
|
||||
});
|
||||
});
|
37
ts/tests/docx/run/strikeTests.ts
Normal file
37
ts/tests/docx/run/strikeTests.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {Strike, DoubleStrike} from "../../../docx/run/strike";
|
||||
import {assert} from "chai";
|
||||
|
||||
function jsonify(obj: Object) {
|
||||
let stringifiedJson = JSON.stringify(obj);
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
describe("Strike", () => {
|
||||
let strike: Strike;
|
||||
|
||||
beforeEach(() => {
|
||||
strike = new Strike();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Strike with correct root key", () => {
|
||||
let newJson = jsonify(strike);
|
||||
assert.equal(newJson.rootKey, "w:strike");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("DoubleStrike", () => {
|
||||
let strike: DoubleStrike;
|
||||
|
||||
beforeEach(() => {
|
||||
strike = new DoubleStrike();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Double Strike with correct root key", () => {
|
||||
let newJson = jsonify(strike);
|
||||
assert.equal(newJson.rootKey, "w:dstrike");
|
||||
});
|
||||
});
|
||||
});
|
22
ts/tests/docx/run/tabTests.ts
Normal file
22
ts/tests/docx/run/tabTests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import {Tab} from "../../../docx/run/tab";
|
||||
import {assert} from "chai";
|
||||
|
||||
function jsonify(obj: Object) {
|
||||
let stringifiedJson = JSON.stringify(obj);
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
describe("Tab", () => {
|
||||
let tab: Tab;
|
||||
|
||||
beforeEach(() => {
|
||||
tab = new Tab();
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Tab with correct root key", () => {
|
||||
let newJson = jsonify(tab);
|
||||
assert.equal(newJson.rootKey, "w:tab");
|
||||
});
|
||||
});
|
||||
});
|
36
ts/tests/docx/xml-components/xmlUnitTests.ts
Normal file
36
ts/tests/docx/xml-components/xmlUnitTests.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import {XmlUnitComponent} from "../../../docx/xml-components";
|
||||
import {assert} from "chai";
|
||||
|
||||
function jsonify(obj: Object) {
|
||||
let stringifiedJson = JSON.stringify(obj);
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
class TestComponent extends XmlUnitComponent {
|
||||
|
||||
}
|
||||
|
||||
describe("XmlUnitComponent", () => {
|
||||
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 not replace the key to the specified root key as root is null", () => {
|
||||
xmlComponent.replaceKey();
|
||||
let newJson = jsonify(xmlComponent);
|
||||
assert.isUndefined(newJson["w:test"]);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user