Skip to content

Commit

Permalink
feat(chromium): update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cherfia committed Nov 4, 2023
1 parent f31adf4 commit 90a076b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/chromium/converters/tests/html.converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import FormData from "form-data";

import { PdfFormat } from "../../../common";
import { HtmlConverter } from "../html.converter";
import { EmulatedMediaType } from "../../../common/constants";

const { Response } = jest.requireActual("node-fetch");
jest.mock("node-fetch", () => jest.fn());
Expand Down Expand Up @@ -103,7 +102,7 @@ describe("HtmlConverter", () => {
mockFetch.mockResolvedValue(new Response("content"));
const buffer = await converter.convert({
html: "path/to/index.html",
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
});
expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
expect(buffer).toEqual(Buffer.from("content"));
Expand All @@ -119,7 +118,7 @@ describe("HtmlConverter", () => {
header: "path/to/header.html",
footer: "path/to/footer.html",
pdfFormat: PdfFormat.A_1a,
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
properties: { size: { width: 8.3, height: 11.7 } },
});
expect(mockFormDataAppend).toHaveBeenCalledTimes(7);
Expand Down
5 changes: 2 additions & 3 deletions src/chromium/converters/tests/markdown.converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import fetch from "node-fetch";

import { PdfFormat } from "../../../common";
import { MarkdownConverter } from "../markdown.converter";
import { EmulatedMediaType } from "../../../common/constants";

const { Response } = jest.requireActual("node-fetch");
jest.mock("node-fetch", () => jest.fn());
Expand Down Expand Up @@ -111,7 +110,7 @@ describe("MarkdownConverter", () => {
const buffer = await converter.convert({
html: "path/to/index.html",
markdown: "path/to/file.md",
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
});

expect(mockFormDataAppend).toHaveBeenCalledTimes(3);
Expand All @@ -129,7 +128,7 @@ describe("MarkdownConverter", () => {
header: "path/to/header.html",
footer: "path/to/footer.html",
pdfFormat: PdfFormat.A_1a,
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
properties: { size: { width: 8.3, height: 11.7 } },
});
expect(mockFormDataAppend).toHaveBeenCalledTimes(8);
Expand Down
5 changes: 2 additions & 3 deletions src/chromium/converters/tests/url.converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import fetch from "node-fetch";

import { PdfFormat } from "../../../common";
import { UrlConverter } from "../url.converter";
import { EmulatedMediaType } from "../../../common/constants";

const { Response } = jest.requireActual("node-fetch");
jest.mock("node-fetch", () => jest.fn());
Expand Down Expand Up @@ -104,7 +103,7 @@ describe("HtmlConverter", () => {
mockFetch.mockResolvedValue(new Response("content"));
const buffer = await converter.convert({
url: "http://www.example.com/",
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
});
expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
expect(buffer).toEqual(Buffer.from("content"));
Expand All @@ -120,7 +119,7 @@ describe("HtmlConverter", () => {
header: "path/to/header.html",
footer: "path/to/footer.html",
pdfFormat: PdfFormat.A_1a,
emulatedMediaType: EmulatedMediaType.SCREEN,
emulatedMediaType: "screen",
properties: { size: { width: 8.3, height: 11.7 } },
});
expect(mockFormDataAppend).toHaveBeenCalledTimes(7);
Expand Down

0 comments on commit 90a076b

Please sign in to comment.