#1583 Add more tests to media data
This commit is contained in:
@ -4,7 +4,8 @@ import * as sinon from "sinon";
|
|||||||
|
|
||||||
import { File } from "@file/file";
|
import { File } from "@file/file";
|
||||||
import { Footer, Header } from "@file/header";
|
import { Footer, Header } from "@file/header";
|
||||||
import { Paragraph } from "@file/paragraph";
|
import { ImageRun, Paragraph } from "@file/paragraph";
|
||||||
|
import * as convenienceFunctions from "@util/convenience-functions";
|
||||||
|
|
||||||
import { Compiler } from "./next-compiler";
|
import { Compiler } from "./next-compiler";
|
||||||
|
|
||||||
@ -15,6 +16,14 @@ describe("Compiler", () => {
|
|||||||
compiler = new Compiler();
|
compiler = new Compiler();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
sinon.stub(convenienceFunctions, "uniqueId").callsFake(() => "test");
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
(convenienceFunctions.uniqueId as sinon.SinonStub).restore();
|
||||||
|
});
|
||||||
|
|
||||||
describe("#compile()", () => {
|
describe("#compile()", () => {
|
||||||
it("should pack all the content", async function () {
|
it("should pack all the content", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
@ -117,12 +126,32 @@ describe("Compiler", () => {
|
|||||||
it("should work with media datas", () => {
|
it("should work with media datas", () => {
|
||||||
// This test is required because before, there was a case where Document was formatted twice, which was inefficient
|
// This test is required because before, there was a case where Document was formatted twice, which was inefficient
|
||||||
// This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
|
// This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
|
||||||
const paragraph = new Paragraph("");
|
|
||||||
const file = new File({
|
const file = new File({
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
properties: {},
|
headers: {
|
||||||
children: [paragraph],
|
default: new Header({
|
||||||
|
children: [new Paragraph("test")],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
footers: {
|
||||||
|
default: new Footer({
|
||||||
|
children: [new Paragraph("test")],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: Buffer.from("", "base64"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user