Add prepForXml test

This commit is contained in:
Dolan Miu
2020-10-12 22:48:38 +01:00
parent daea8d2868
commit 102d6aa55c

View File

@ -5,8 +5,9 @@ import { stub } from "sinon";
import { Formatter } from "export/formatter"; import { Formatter } from "export/formatter";
import { EMPTY_OBJECT } from "file/xml-components"; import { EMPTY_OBJECT } from "file/xml-components";
import { File } from "../file";
import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting"; import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting";
import { Bookmark } from "./links"; import { Bookmark, HyperlinkRef } from "./links";
import { Paragraph } from "./paragraph"; import { Paragraph } from "./paragraph";
describe("Paragraph", () => { describe("Paragraph", () => {
@ -759,4 +760,23 @@ describe("Paragraph", () => {
}); });
}); });
}); });
describe("#prepForXml", () => {
it("should set paragraph outline level to the given value", () => {
const paragraph = new Paragraph({
children: [new HyperlinkRef("myAnchorId")],
});
const fileMock = ({
HyperlinkCache: {
myAnchorId: "test",
},
// tslint:disable-next-line: no-any
} as any) as File;
paragraph.prepForXml(fileMock);
const tree = new Formatter().format(paragraph);
expect(tree).to.deep.equal({
"w:p": ["test"],
});
});
});
}); });