Remove unused code and improve coverage

This commit is contained in:
Dolan
2019-12-24 00:44:15 +00:00
parent b83d2c388f
commit de03f19b46
5 changed files with 35 additions and 10 deletions

View File

@ -4,10 +4,6 @@ import * as shortid from "shortid";
import { TextRun } from "../run"; import { TextRun } from "../run";
import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attributes"; import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attributes";
export class BookmarkRef {
constructor(public readonly name: string, public readonly text: string) {}
}
export class Bookmark { export class Bookmark {
public readonly start: BookmarkStart; public readonly start: BookmarkStart;
public readonly text: TextRun; public readonly text: TextRun;

View File

@ -3,6 +3,7 @@ import { expect } from "chai";
import { Formatter } from "export/formatter"; import { Formatter } from "export/formatter";
import { Hyperlink } from "./"; import { Hyperlink } from "./";
import { HyperlinkRef } from "./hyperlink";
describe("Hyperlink", () => { describe("Hyperlink", () => {
let hyperlink: Hyperlink; let hyperlink: Hyperlink;
@ -59,3 +60,11 @@ describe("Hyperlink", () => {
}); });
}); });
}); });
describe("HyperlinkRef", () => {
describe("#constructor()", () => {
const hyperlinkRef = new HyperlinkRef("test-id");
expect(hyperlinkRef.id).to.equal("test-id");
});
});

View File

@ -13,7 +13,7 @@ import { ContextualSpacing, ISpacingProperties, Spacing } from "./formatting/spa
import { HeadingLevel, Style } from "./formatting/style"; import { HeadingLevel, Style } from "./formatting/style";
import { LeaderType, TabStop, TabStopPosition, TabStopType } from "./formatting/tab-stop"; import { LeaderType, TabStop, TabStopPosition, TabStopType } from "./formatting/tab-stop";
import { NumberProperties } from "./formatting/unordered-list"; import { NumberProperties } from "./formatting/unordered-list";
import { Bookmark, BookmarkRef, HyperlinkRef, OutlineLevel } from "./links"; import { Bookmark, HyperlinkRef, OutlineLevel } from "./links";
import { ParagraphProperties } from "./properties"; import { ParagraphProperties } from "./properties";
import { PictureRun, Run, SequentialIdentifier, SymbolRun, TextRun } from "./run"; import { PictureRun, Run, SequentialIdentifier, SymbolRun, TextRun } from "./run";
@ -46,7 +46,7 @@ export interface IParagraphOptions {
readonly custom?: boolean; readonly custom?: boolean;
}; };
readonly children?: Array< readonly children?: Array<
TextRun | PictureRun | SymbolRun | Bookmark | PageBreak | SequentialIdentifier | FootnoteReferenceRun | HyperlinkRef | BookmarkRef TextRun | PictureRun | SymbolRun | Bookmark | PageBreak | SequentialIdentifier | FootnoteReferenceRun | HyperlinkRef
>; >;
} }

View File

@ -7,10 +7,6 @@ export class PictureRun extends Run {
constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) { constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) {
super({}); super({});
if (imageData === undefined) {
throw new Error("imageData cannot be undefined");
}
const drawing = new Drawing(imageData, drawingOptions); const drawing = new Drawing(imageData, drawingOptions);
this.root.push(drawing); this.root.push(drawing);

View File

@ -132,6 +132,30 @@ describe("Run", () => {
}); });
}); });
describe("#subScript()", () => {
it("it should add subScript to the properties", () => {
const run = new Run({
subScript: true,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [{ "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }] }],
});
});
});
describe("#superScript()", () => {
it("it should add superScript to the properties", () => {
const run = new Run({
superScript: true,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [{ "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }] }],
});
});
});
describe("#highlight()", () => { describe("#highlight()", () => {
it("it should add highlight to the properties", () => { it("it should add highlight to the properties", () => {
const run = new Run({ const run = new Run({