move run-fonts to docx/run and add a test
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import {XmlAttributeComponent, XmlComponent} from "../docx/xml-components";
|
||||
import {XmlAttributeComponent, XmlComponent} from "../xml-components";
|
||||
|
||||
interface IRunFontAttributesProperties {
|
||||
ascii: string;
|
||||
hAnsi: string;
|
||||
hint: string;
|
||||
hint?: string;
|
||||
}
|
||||
|
||||
class RunFontAttributes extends XmlAttributeComponent {
|
||||
@ -19,7 +19,7 @@ class RunFontAttributes extends XmlAttributeComponent {
|
||||
|
||||
export class RunFonts extends XmlComponent {
|
||||
|
||||
constructor(ascii: string, hint: string) {
|
||||
constructor(ascii: string, hint?: string) {
|
||||
super("w:rFonts");
|
||||
this.root.push(new RunFontAttributes({
|
||||
ascii: ascii,
|
@ -1,11 +1,11 @@
|
||||
import * as _ from "lodash";
|
||||
import { DocumentAttributes } from "../docx/document/document-attributes";
|
||||
import { RunFonts } from "../docx/run/run-fonts";
|
||||
import { MultiPropertyXmlComponent } from "../docx/xml-components";
|
||||
import { AbstractNumbering } from "./abstract-numbering";
|
||||
import { Indent } from "./indent";
|
||||
import { Level } from "./level";
|
||||
import { Num } from "./num";
|
||||
import { RunFonts } from "./run-fonts";
|
||||
|
||||
export class Numbering extends MultiPropertyXmlComponent {
|
||||
private nextId: number;
|
||||
|
22
ts/tests/docx/run/fontTests.ts
Normal file
22
ts/tests/docx/run/fontTests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { expect } from "chai";
|
||||
import { RunFonts } from "../../../docx/run/run-fonts";
|
||||
import { Formatter } from "../../../export/formatter";
|
||||
|
||||
describe("RunFonts", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("uses the font name for both ascii and hAnsi", () => {
|
||||
const tree = new Formatter().format(new RunFonts("Times"));
|
||||
expect(tree).to.deep.equal({
|
||||
"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}],
|
||||
});
|
||||
});
|
||||
|
||||
it("uses hint if given", () => {
|
||||
const tree = new Formatter().format(new RunFonts("Times", "default"));
|
||||
expect(tree).to.deep.equal({
|
||||
"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times", "w:hint": "default"}}],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user