docx
Version:
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
38 lines (32 loc) • 1.26 kB
text/typescript
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { Underline, UnderlineType } from "./underline";
describe("Underline", () => {
describe("#constructor()", () => {
it("should create a new Underline object with u:u as the rootKey", () => {
const underline = new Underline();
const tree = new Formatter().format(underline);
expect(tree).to.deep.equal({
"w:u": {
_attr: {
"w:val": "single",
},
},
});
});
it("should default to 'single' and no color", () => {
const underline = new 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 Underline(UnderlineType.DOUBLE, "FF00CC");
const tree = new Formatter().format(underline);
expect(tree).to.deep.equal({
"w:u": { _attr: { "w:val": "double", "w:color": "FF00CC" } },
});
});
});
});