allow Run#underline to take style and color arguments

This commit is contained in:
felipe
2017-03-12 17:28:52 +01:00
parent db24f67e34
commit d85c6ce56a
2 changed files with 22 additions and 2 deletions

View File

@ -29,8 +29,8 @@ export class Run extends XmlComponent {
return this; return this;
} }
public underline(): Run { public underline(underlineType?: string, color?: string): Run {
this.properties.push(new Underline()); this.properties.push(new Underline(underlineType, color));
return this; return this;
} }

View File

@ -32,6 +32,26 @@ describe("Run", () => {
const newJson = Utility.jsonify(run); const newJson = Utility.jsonify(run);
assert.equal(newJson.root[0].root[0].rootKey, "w:u"); 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()", () => { describe("#smallCaps()", () => {