Add tests
This commit is contained in:
22
src/file/paragraph/run/formatting.spec.ts
Normal file
22
src/file/paragraph/run/formatting.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { Bold } from "./formatting";
|
||||
|
||||
describe("Bold", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should create", () => {
|
||||
const currentBold = new Bold();
|
||||
|
||||
const tree = new Formatter().format(currentBold);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:b": {
|
||||
_attr: {
|
||||
"w:val": true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,10 +1,5 @@
|
||||
import { Attributes, XmlComponent } from "file/xml-components";
|
||||
|
||||
export { Underline } from "./underline";
|
||||
export { EmphasisMark } from "./emphasis-mark";
|
||||
export { SubScript, SuperScript } from "./script";
|
||||
export { RunFonts, IFontAttributesProperties } from "./run-fonts";
|
||||
|
||||
export class Bold extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:b");
|
||||
|
@ -8,8 +8,10 @@ import {
|
||||
CharacterSpacing,
|
||||
Color,
|
||||
DoubleStrike,
|
||||
Emboss,
|
||||
Highlight,
|
||||
HighlightComplexScript,
|
||||
Imprint,
|
||||
Italics,
|
||||
ItalicsComplexScript,
|
||||
RightToLeft,
|
||||
@ -63,6 +65,8 @@ export interface IRunStylePropertiesOptions {
|
||||
};
|
||||
readonly shadingComplexScript?: boolean | IRunStylePropertiesOptions["shading"];
|
||||
readonly shadow?: IRunStylePropertiesOptions["shading"];
|
||||
readonly emboss?: boolean;
|
||||
readonly imprint?: boolean;
|
||||
}
|
||||
|
||||
export interface IRunPropertiesOptions extends IRunStylePropertiesOptions {
|
||||
@ -169,6 +173,14 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent {
|
||||
this.push(new CharacterSpacing(options.characterSpacing));
|
||||
}
|
||||
|
||||
if (options.emboss) {
|
||||
this.push(new Emboss());
|
||||
}
|
||||
|
||||
if (options.imprint) {
|
||||
this.push(new Imprint());
|
||||
}
|
||||
|
||||
const shading = options.shading || options.shadow;
|
||||
if (shading) {
|
||||
this.push(new Shading(shading.type, shading.fill, shading.color));
|
||||
|
@ -146,7 +146,7 @@ describe("Run", () => {
|
||||
});
|
||||
|
||||
describe("#doubleStrike()", () => {
|
||||
it("it should add caps to the properties", () => {
|
||||
it("it should add double strike to the properties", () => {
|
||||
const run = new Run({
|
||||
doubleStrike: true,
|
||||
});
|
||||
@ -157,6 +157,30 @@ describe("Run", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#emboss()", () => {
|
||||
it("it should add emboss to the properties", () => {
|
||||
const run = new Run({
|
||||
emboss: true,
|
||||
});
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:emboss": { _attr: { "w:val": true } } }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#imprint()", () => {
|
||||
it("it should add imprint to the properties", () => {
|
||||
const run = new Run({
|
||||
imprint: true,
|
||||
});
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:imprint": { _attr: { "w:val": true } } }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#subScript()", () => {
|
||||
it("it should add subScript to the properties", () => {
|
||||
const run = new Run({
|
||||
|
Reference in New Issue
Block a user