Files
docx-js/ts/tests/docx/paragraph/tabStopTests.ts
2017-03-07 22:15:53 +00:00

60 lines
1.6 KiB
TypeScript

import { LeftTabStop, MaxRightTabStop } from "../../../docx/paragraph/tab-stop";
import { assert } from "chai";
function jsonify(obj: Object) {
let stringifiedJson = JSON.stringify(obj);
return JSON.parse(stringifiedJson);
}
describe("LeftTabStop", () => {
let tabStop: LeftTabStop;
beforeEach(() => {
tabStop = new LeftTabStop(100);
});
describe("#constructor()", () => {
it("should create a Tab Stop with correct attributes", () => {
let newJson = jsonify(tabStop);
let attributes = {
val: "left",
pos: 100
};
assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes));
});
it("should create a Tab Stop with w:tab", () => {
let newJson = jsonify(tabStop);
assert.equal(newJson.root[0].rootKey, "w:tab");
});
});
});
describe("RightTabStop", () => {
});
describe("MaxRightTabStop", () => {
let tabStop: MaxRightTabStop;
beforeEach(() => {
tabStop = new MaxRightTabStop();
});
describe("#constructor()", () => {
it("should create a Tab Stop with correct attributes", () => {
let newJson = jsonify(tabStop);
let attributes = {
val: "right",
pos: 9026
};
assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes));
});
it("should create a Tab Stop with w:tab", () => {
let newJson = jsonify(tabStop);
assert.equal(newJson.root[0].rootKey, "w:tab");
});
});
});