Turn Packer static

This commit is contained in:
Dolan
2019-08-07 22:12:14 +01:00
parent 65c5177daf
commit d8b60d82f3
51 changed files with 118 additions and 183 deletions

View File

@ -7,7 +7,6 @@ import { File, HeadingLevel, Paragraph } from "file";
import { Packer } from "./packer";
describe("Packer", () => {
let packer: Packer;
let file: File;
beforeEach(() => {
@ -34,14 +33,12 @@ describe("Packer", () => {
new Paragraph("test text"),
],
});
packer = new Packer();
});
describe("#toBuffer()", () => {
it("should create a standard docx file", async function() {
this.timeout(99999999);
const buffer = await packer.toBuffer(file);
const buffer = await Packer.toBuffer(file);
assert.isDefined(buffer);
assert.isTrue(buffer.byteLength > 0);
@ -49,10 +46,10 @@ describe("Packer", () => {
it("should handle exception if it throws any", () => {
// tslint:disable-next-line:no-any
const compiler = stub((packer as any).compiler, "compile");
const compiler = stub((Packer as any).compiler, "compile");
compiler.throwsException();
return packer.toBuffer(file).catch((error) => {
return Packer.toBuffer(file).catch((error) => {
assert.isDefined(error);
});
});
@ -61,7 +58,7 @@ describe("Packer", () => {
describe("#toBase64String()", () => {
it("should create a standard docx file", async function() {
this.timeout(99999999);
const str = await packer.toBase64String(file);
const str = await Packer.toBase64String(file);
assert.isDefined(str);
assert.isTrue(str.length > 0);
@ -69,10 +66,10 @@ describe("Packer", () => {
it("should handle exception if it throws any", () => {
// tslint:disable-next-line:no-any
const compiler = stub((packer as any).compiler, "compile");
const compiler = stub((Packer as any).compiler, "compile");
compiler.throwsException();
return packer.toBase64String(file).catch((error) => {
return Packer.toBase64String(file).catch((error) => {
assert.isDefined(error);
});
});