add #font method to Run

This commit is contained in:
felipe
2017-03-08 20:29:12 +01:00
parent 81e0d56918
commit 1a37242a3d
2 changed files with 24 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { assert } from "chai";
import { assert, expect } from "chai";
import { Run } from "../../../docx/run";
import { TextRun } from "../../../docx/run/text-run";
import { Formatter } from "../../../export/formatter";
@ -85,4 +85,20 @@ describe("Run", () => {
assert.equal(newJson.root[1].rootKey, "w:tab");
});
});
describe("#font()", () => {
it("should allow chaining calls", () => {
expect(run.font("Times")).to.equal(run);
});
it("should set the font as named", () => {
run.font("Times");
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{"w:rPr": [{"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}]}]},
],
});
});
});
});