allow Underline to be called with type and color; fix default
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
export { Underline } from './underline';
|
||||||
|
|
||||||
export class Bold extends XmlComponent {
|
export class Bold extends XmlComponent {
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ abstract class BaseUnderline extends XmlComponent {
|
|||||||
|
|
||||||
export class Underline extends BaseUnderline {
|
export class Underline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor(underlineType: string = "single", color?: string) {
|
||||||
super("");
|
super(underlineType, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { assert } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
import { TextRun } from "../../../docx/run/text-run";
|
import { TextRun } from "../../../docx/run/text-run";
|
||||||
import * as u from "../../../docx/run/underline";
|
import * as u from "../../../docx/run/underline";
|
||||||
|
import { Formatter } from "../../../export/formatter";
|
||||||
|
|
||||||
function jsonify(obj: object) {
|
function jsonify(obj: object) {
|
||||||
const stringifiedJson = JSON.stringify(obj);
|
const stringifiedJson = JSON.stringify(obj);
|
||||||
@ -17,6 +18,22 @@ describe("Underline", () => {
|
|||||||
const newJson = jsonify(underline);
|
const newJson = jsonify(underline);
|
||||||
assert.equal(newJson.rootKey, "w:u");
|
assert.equal(newJson.rootKey, "w:u");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should default to 'single' and no color", () => {
|
||||||
|
const underline = new u.Underline();
|
||||||
|
const tree = new Formatter().format(underline);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:u": [{_attr: {"w:val": "single"}}],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use the given style type and color", () => {
|
||||||
|
const underline = new u.Underline("double", "FF00CC");
|
||||||
|
const tree = new Formatter().format(underline);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:u": [{_attr: {"w:val": "double", "w:color": "FF00CC"}}],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user