diff --git a/src/file/paragraph/formatting/tab-stop.spec.ts b/src/file/paragraph/formatting/tab-stop.spec.ts index bb9fa80d96..465b4deb36 100644 --- a/src/file/paragraph/formatting/tab-stop.spec.ts +++ b/src/file/paragraph/formatting/tab-stop.spec.ts @@ -1,7 +1,7 @@ import { assert } from "chai"; import { Utility } from "../../../tests/utility"; -import { LeftTabStop, MaxRightTabStop } from "./tab-stop"; +import { LeftTabStop, RightTabStop, MaxRightTabStop } from "./tab-stop"; describe("LeftTabStop", () => { let tabStop: LeftTabStop; @@ -28,7 +28,28 @@ describe("LeftTabStop", () => { }); describe("RightTabStop", () => { - // TODO + let tabStop: RightTabStop; + + beforeEach(() => { + tabStop = new RightTabStop(100, "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"); + }); + }); }); describe("MaxRightTabStop", () => { diff --git a/src/file/paragraph/formatting/tab-stop.ts b/src/file/paragraph/formatting/tab-stop.ts index 3159a12177..bcaeee8371 100644 --- a/src/file/paragraph/formatting/tab-stop.ts +++ b/src/file/paragraph/formatting/tab-stop.ts @@ -11,7 +11,7 @@ export class TabStop extends XmlComponent { export type TabValue = "left" | "right" | "center" | "bar" | "clear" | "decimal" | "end" | "num" | "start"; export type LeaderType = "dot" | "hyphen" | "middleDot" | "none" | "underscore"; -export class TabAttributes extends XmlAttributeComponent<{ val: TabValue; pos: string | number; leader: LeaderType }> { +export class TabAttributes extends XmlAttributeComponent<{ val: TabValue; pos: string | number; leader?: LeaderType }> { protected xmlKeys = { val: "w:val", pos: "w:pos", leader: "w:leader" }; } @@ -22,7 +22,7 @@ export class TabStopItem extends XmlComponent { new TabAttributes({ val: value, pos: position, - leader: leader || "none", + leader, }), ); }