making leader a option field and test improvments
This commit is contained in:
@ -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", () => {
|
||||
|
@ -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,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user