Files
docx-js/src/file/paragraph/formatting/tab-stop.spec.ts

55 lines
1.6 KiB
TypeScript
Raw Normal View History

import { assert } from "chai";
2018-10-26 01:04:07 +01:00
import { Utility } from "tests/utility";
2019-10-09 20:56:31 +01:00
import { LeaderType, TabStop, TabStopType } from "./tab-stop";
2016-07-15 18:50:54 +01:00
describe("LeftTabStop", () => {
2019-10-09 20:56:31 +01:00
let tabStop: TabStop;
2016-07-15 18:50:54 +01:00
beforeEach(() => {
2019-10-09 20:56:31 +01:00
tabStop = new TabStop(TabStopType.LEFT, 100);
2016-07-15 18:50:54 +01:00
});
describe("#constructor()", () => {
it("should create a Tab Stop with correct attributes", () => {
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(tabStop);
const attributes = {
2016-07-15 18:50:54 +01:00
val: "left",
2017-03-09 22:56:08 +00:00
pos: 100,
2016-07-15 18:50:54 +01:00
};
assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes));
});
it("should create a Tab Stop with w:tab", () => {
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(tabStop);
2016-07-15 18:50:54 +01:00
assert.equal(newJson.root[0].rootKey, "w:tab");
});
});
});
describe("RightTabStop", () => {
2019-10-09 20:56:31 +01:00
let tabStop: TabStop;
beforeEach(() => {
2019-10-09 20:56:31 +01:00
tabStop = new TabStop(TabStopType.RIGHT, 100, LeaderType.DOT);
});
describe("#constructor()", () => {
it("should create a Tab Stop with correct attributes", () => {
const newJson = Utility.jsonify(tabStop);
const attributes = {
val: "right",
pos: 100,
leader: "dot",
};
assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes));
});
it("should create a Tab Stop with w:tab", () => {
const newJson = Utility.jsonify(tabStop);
assert.equal(newJson.root[0].rootKey, "w:tab");
});
});
2016-07-15 18:50:54 +01:00
});