diff --git a/ts/docx/run/index.ts b/ts/docx/run/index.ts index 6585de6c01..80417d05fb 100644 --- a/ts/docx/run/index.ts +++ b/ts/docx/run/index.ts @@ -29,8 +29,8 @@ export class Run extends XmlComponent { return this; } - public underline(): Run { - this.properties.push(new Underline()); + public underline(underlineType?: string, color?: string): Run { + this.properties.push(new Underline(underlineType, color)); return this; } diff --git a/ts/tests/docx/run/runTest.ts b/ts/tests/docx/run/runTest.ts index 1bdc1718f0..a4587a05c8 100644 --- a/ts/tests/docx/run/runTest.ts +++ b/ts/tests/docx/run/runTest.ts @@ -32,6 +32,26 @@ describe("Run", () => { const newJson = Utility.jsonify(run); assert.equal(newJson.root[0].root[0].rootKey, "w:u"); }); + + it("should default to 'single' and no color", () => { + run.underline(); + const tree = new Formatter().format(run); + expect(tree).to.deep.equal({ + "w:r": [ + {"w:rPr": [{"w:u": [{_attr: {"w:val": "single"}}]}]}, + ], + }); + }); + + it("should set the style type and color if given", () => { + run.underline("double", "990011"); + const tree = new Formatter().format(run); + expect(tree).to.deep.equal({ + "w:r": [ + {"w:rPr": [{"w:u": [{_attr: {"w:val": "double", "w:color": "990011"}}]}]}, + ], + }); + }); }); describe("#smallCaps()", () => {