chromiumly 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +55 -35
  2. package/dist/chromium/converters/converter.d.ts +1 -1
  3. package/dist/chromium/converters/converter.js +1 -1
  4. package/dist/chromium/converters/converter.js.map +1 -1
  5. package/dist/chromium/converters/html.converter.d.ts +9 -4
  6. package/dist/chromium/converters/html.converter.js +7 -3
  7. package/dist/chromium/converters/html.converter.js.map +1 -1
  8. package/dist/chromium/converters/markdown.converter.d.ts +9 -4
  9. package/dist/chromium/converters/markdown.converter.js +7 -3
  10. package/dist/chromium/converters/markdown.converter.js.map +1 -1
  11. package/dist/chromium/converters/url.converter.d.ts +9 -4
  12. package/dist/chromium/converters/url.converter.js +6 -2
  13. package/dist/chromium/converters/url.converter.js.map +1 -1
  14. package/dist/chromium/index.d.ts +3 -3
  15. package/dist/chromium/index.js.map +1 -1
  16. package/dist/chromium/interfaces/common.types.d.ts +13 -0
  17. package/dist/chromium/interfaces/common.types.js +3 -0
  18. package/dist/chromium/interfaces/common.types.js.map +1 -0
  19. package/dist/chromium/interfaces/converter.types.d.ts +4 -10
  20. package/dist/chromium/utils/converter.utils.d.ts +2 -12
  21. package/dist/chromium/utils/converter.utils.js +36 -50
  22. package/dist/chromium/utils/converter.utils.js.map +1 -1
  23. package/dist/common/gotenberg.utils.d.ts +11 -1
  24. package/dist/common/gotenberg.utils.js +25 -2
  25. package/dist/common/gotenberg.utils.js.map +1 -1
  26. package/dist/common/index.d.ts +3 -3
  27. package/dist/common/index.js.map +1 -1
  28. package/dist/common/types.d.ts +1 -1
  29. package/dist/gotenberg.js +4 -3
  30. package/dist/gotenberg.js.map +1 -1
  31. package/dist/libre-office/index.d.ts +2 -2
  32. package/dist/libre-office/index.js.map +1 -1
  33. package/dist/libre-office/utils/constants.js +80 -76
  34. package/dist/libre-office/utils/constants.js.map +1 -1
  35. package/dist/libre-office/utils/libre-office.utils.d.ts +3 -3
  36. package/dist/libre-office/utils/libre-office.utils.js +5 -5
  37. package/dist/libre-office/utils/libre-office.utils.js.map +1 -1
  38. package/dist/main.config.d.ts +1 -1
  39. package/dist/main.config.js +6 -6
  40. package/dist/main.config.js.map +1 -1
  41. package/dist/main.d.ts +3 -3
  42. package/dist/main.js.map +1 -1
  43. package/dist/pdf-engines/index.d.ts +1 -1
  44. package/dist/pdf-engines/index.js.map +1 -1
  45. package/dist/pdf-engines/pdf.engine.d.ts +3 -3
  46. package/dist/pdf-engines/pdf.engine.js +5 -5
  47. package/dist/pdf-engines/pdf.engine.js.map +1 -1
  48. package/dist/pdf-engines/utils/engine.utils.d.ts +2 -2
  49. package/dist/pdf-engines/utils/engine.utils.js +3 -3
  50. package/dist/pdf-engines/utils/engine.utils.js.map +1 -1
  51. package/package.json +20 -12
  52. package/src/.prettierrc.yml +4 -0
  53. package/src/chromium/converters/converter.ts +2 -2
  54. package/src/chromium/converters/html.converter.ts +37 -27
  55. package/src/chromium/converters/markdown.converter.ts +32 -26
  56. package/src/chromium/converters/tests/html.converter.test.ts +97 -73
  57. package/src/chromium/converters/tests/markdown.converter.test.ts +102 -77
  58. package/src/chromium/converters/tests/url.converter.test.ts +90 -66
  59. package/src/chromium/converters/url.converter.ts +31 -25
  60. package/src/chromium/index.ts +3 -3
  61. package/src/chromium/interfaces/common.types.ts +15 -0
  62. package/src/chromium/interfaces/converter.types.ts +4 -12
  63. package/src/chromium/utils/converter.utils.ts +67 -60
  64. package/src/chromium/utils/tests/converter.utils.test.ts +237 -167
  65. package/src/common/constants.ts +3 -3
  66. package/src/common/gotenberg.utils.ts +39 -8
  67. package/src/common/index.ts +3 -3
  68. package/src/common/tests/gotenberg.utils.test.ts +38 -31
  69. package/src/common/types.ts +2 -2
  70. package/src/gotenberg.ts +9 -9
  71. package/src/libre-office/index.ts +2 -2
  72. package/src/libre-office/utils/constants.ts +80 -76
  73. package/src/libre-office/utils/libre-office.utils.ts +21 -18
  74. package/src/libre-office/utils/tests/libre-office.utils.test.ts +58 -49
  75. package/src/main.config.ts +13 -13
  76. package/src/main.ts +3 -3
  77. package/src/pdf-engines/index.ts +1 -1
  78. package/src/pdf-engines/pdf.engine.ts +23 -19
  79. package/src/pdf-engines/tests/pdf.engine.test.ts +52 -49
  80. package/src/pdf-engines/utils/engine.utils.ts +12 -9
  81. package/src/pdf-engines/utils/tests/engine.utils.test.ts +23 -23
@@ -1,13 +1,13 @@
1
- import {Gotenberg} from "./gotenberg";
1
+ import { Gotenberg } from './gotenberg';
2
2
 
3
3
  /**
4
4
  * Enum representing the available Chromium routes for conversion.
5
5
  * @enum {string}
6
6
  */
7
7
  export enum ChromiumRoute {
8
- URL = "url",
9
- HTML = "html",
10
- MARKDOWN = "markdown",
8
+ URL = 'url',
9
+ HTML = 'html',
10
+ MARKDOWN = 'markdown'
11
11
  }
12
12
 
13
13
  /**
@@ -15,7 +15,7 @@ export enum ChromiumRoute {
15
15
  * @enum {string}
16
16
  */
17
17
  enum PdfEngineRoute {
18
- MERGE = "merge",
18
+ MERGE = 'merge'
19
19
  }
20
20
 
21
21
  /**
@@ -23,7 +23,7 @@ enum PdfEngineRoute {
23
23
  * @enum {string}
24
24
  */
25
25
  enum LibreOfficeRoute {
26
- CONVERT = "convert",
26
+ CONVERT = 'convert'
27
27
  }
28
28
 
29
29
  /**
@@ -40,19 +40,19 @@ export class Chromiumly {
40
40
  * The path for Chromium-related conversions.
41
41
  * @type {string}
42
42
  */
43
- public static readonly CHROMIUM_PATH = "forms/chromium/convert";
43
+ public static readonly CHROMIUM_CONVERT_PATH = 'forms/chromium/convert';
44
44
 
45
45
  /**
46
46
  * The path for PDF engine-related operations.
47
47
  * @type {string}
48
48
  */
49
- public static readonly PDF_ENGINES_PATH = "forms/pdfengines";
49
+ public static readonly PDF_ENGINES_PATH = 'forms/pdfengines';
50
50
 
51
51
  /**
52
52
  * The path for LibreOffice-related conversions.
53
53
  * @type {string}
54
54
  */
55
- public static readonly LIBRE_OFFICE_PATH = "forms/libreoffice";
55
+ public static readonly LIBRE_OFFICE_PATH = 'forms/libreoffice';
56
56
 
57
57
  /**
58
58
  * Routes for Chromium conversions.
@@ -61,7 +61,7 @@ export class Chromiumly {
61
61
  public static readonly CHROMIUM_ROUTES = {
62
62
  url: ChromiumRoute.URL,
63
63
  html: ChromiumRoute.HTML,
64
- markdown: ChromiumRoute.MARKDOWN,
64
+ markdown: ChromiumRoute.MARKDOWN
65
65
  };
66
66
 
67
67
  /**
@@ -69,7 +69,7 @@ export class Chromiumly {
69
69
  * @type {Object}
70
70
  */
71
71
  public static readonly PDF_ENGINE_ROUTES = {
72
- merge: PdfEngineRoute.MERGE,
72
+ merge: PdfEngineRoute.MERGE
73
73
  };
74
74
 
75
75
  /**
@@ -77,6 +77,6 @@ export class Chromiumly {
77
77
  * @type {Object}
78
78
  */
79
79
  public static readonly LIBRE_OFFICE_ROUTES = {
80
- convert: LibreOfficeRoute.CONVERT,
80
+ convert: LibreOfficeRoute.CONVERT
81
81
  };
82
- }
82
+ }
package/src/main.ts CHANGED
@@ -1,3 +1,3 @@
1
- export {PdfFormat} from "./common/constants";
2
- export {HtmlConverter, MarkdownConverter, UrlConverter} from "./chromium";
3
- export {PDFEngine} from "./pdf-engines";
1
+ export { PdfFormat } from './common/constants';
2
+ export { HtmlConverter, MarkdownConverter, UrlConverter } from './chromium';
3
+ export { PDFEngine } from './pdf-engines';
@@ -1 +1 @@
1
- export {PDFEngine} from "./pdf.engine";
1
+ export { PDFEngine } from './pdf.engine';
@@ -1,12 +1,12 @@
1
- import {promises} from "fs";
2
- import path from "path";
1
+ import { promises } from 'fs';
2
+ import path from 'path';
3
3
 
4
- import FormData from "form-data";
4
+ import FormData from 'form-data';
5
5
 
6
- import {Chromiumly} from "../main.config";
7
- import {GotenbergUtils, PathLikeOrReadStream, PdfFormat} from "../common";
8
- import {LibreOfficeUtils, PageProperties} from "../libre-office";
9
- import {PDFEngineUtils} from "./utils/engine.utils";
6
+ import { Chromiumly } from '../main.config';
7
+ import { GotenbergUtils, PathLikeOrReadStream, PdfFormat } from '../common';
8
+ import { LibreOfficeUtils, PageProperties } from '../libre-office';
9
+ import { PDFEngineUtils } from './utils/engine.utils';
10
10
 
11
11
  /**
12
12
  * Class representing a PDF engine for various operations such as merging and conversion.
@@ -19,7 +19,11 @@ export class PDFEngine {
19
19
  * @param {PathLikeOrReadStream[]} options.files - An array of PathLikes or ReadStreams to the PDF files to be merged.
20
20
  * @returns {Promise<Buffer>} A Promise resolving to the merged PDF content as a Buffer.
21
21
  */
22
- public static async merge({files}: { files: PathLikeOrReadStream[] }): Promise<Buffer> {
22
+ public static async merge({
23
+ files
24
+ }: {
25
+ files: PathLikeOrReadStream[];
26
+ }): Promise<Buffer> {
23
27
  const data = new FormData();
24
28
  await PDFEngineUtils.addFiles(files, data);
25
29
  const endpoint = `${Chromiumly.GOTENBERG_ENDPOINT}/${Chromiumly.PDF_ENGINES_PATH}/${Chromiumly.PDF_ENGINE_ROUTES.merge}`;
@@ -38,12 +42,12 @@ export class PDFEngine {
38
42
  * @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a Buffer.
39
43
  */
40
44
  public static async convert({
41
- files,
42
- properties,
43
- pdfFormat,
44
- pdfUA,
45
- merge,
46
- }: {
45
+ files,
46
+ properties,
47
+ pdfFormat,
48
+ pdfUA,
49
+ merge
50
+ }: {
47
51
  files: PathLikeOrReadStream[];
48
52
  properties?: PageProperties;
49
53
  pdfFormat?: PdfFormat;
@@ -53,15 +57,15 @@ export class PDFEngine {
53
57
  const data = new FormData();
54
58
 
55
59
  if (pdfFormat) {
56
- data.append("pdfa", pdfFormat);
60
+ data.append('pdfa', pdfFormat);
57
61
  }
58
62
 
59
63
  if (pdfUA) {
60
- data.append("pdfUA", String(pdfUA));
64
+ data.append('pdfUA', String(pdfUA));
61
65
  }
62
66
 
63
67
  if (merge) {
64
- data.append("merge", String(merge));
68
+ data.append('merge', String(merge));
65
69
  }
66
70
 
67
71
  if (properties) {
@@ -86,8 +90,8 @@ export class PDFEngine {
86
90
  filename: string,
87
91
  buffer: Buffer
88
92
  ): Promise<void> {
89
- const __generated__ = path.resolve(process.cwd(), "__generated__");
90
- await promises.mkdir(path.resolve(__generated__), {recursive: true});
93
+ const __generated__ = path.resolve(process.cwd(), '__generated__');
94
+ await promises.mkdir(path.resolve(__generated__), { recursive: true });
91
95
  await promises.writeFile(path.resolve(__generated__, filename), buffer);
92
96
  }
93
97
  }
@@ -1,20 +1,20 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- import {createReadStream, promises} from "fs";
3
- import FormData from "form-data";
4
- import fs from "fs/promises";
5
- import fetch from "node-fetch";
6
- import path from "path";
2
+ import { createReadStream, promises } from 'fs';
3
+ import FormData from 'form-data';
4
+ import fs from 'fs/promises';
5
+ import fetch from 'node-fetch';
6
+ import path from 'path';
7
7
 
8
- import {PdfFormat} from "../../common";
9
- import {PDFEngine} from "../pdf.engine";
8
+ import { PdfFormat } from '../../common';
9
+ import { PDFEngine } from '../pdf.engine';
10
10
 
11
- const {Response} = jest.requireActual("node-fetch");
12
- jest.mock("node-fetch", () => jest.fn());
11
+ const { Response } = jest.requireActual('node-fetch');
12
+ jest.mock('node-fetch', () => jest.fn());
13
13
 
14
- describe("PDFEngine", () => {
15
- const mockPromisesAccess = jest.spyOn(promises, "access");
14
+ describe('PDFEngine', () => {
15
+ const mockPromisesAccess = jest.spyOn(promises, 'access');
16
16
  const mockFetch = fetch as jest.MockedFunction<typeof fetch>;
17
- const mockFormDataAppend = jest.spyOn(FormData.prototype, "append");
17
+ const mockFormDataAppend = jest.spyOn(FormData.prototype, 'append');
18
18
 
19
19
  beforeEach(() => {
20
20
  (createReadStream as jest.Mock) = jest
@@ -26,72 +26,75 @@ describe("PDFEngine", () => {
26
26
  jest.resetAllMocks();
27
27
  });
28
28
 
29
- describe("convert", () => {
30
- describe("when no properties are passed", () => {
31
- it("should return a buffer", async () => {
29
+ describe('convert', () => {
30
+ describe('when no properties are passed', () => {
31
+ it('should return a buffer', async () => {
32
32
  mockPromisesAccess.mockResolvedValue();
33
- mockFetch.mockResolvedValue(new Response("content"));
33
+ mockFetch.mockResolvedValue(new Response('content'));
34
34
  const buffer = await PDFEngine.convert({
35
- files: ["path/to/file.docx", "path/to/file.bib"],
35
+ files: ['path/to/file.docx', 'path/to/file.bib']
36
36
  });
37
- expect(buffer).toEqual(Buffer.from("content"));
37
+ expect(buffer).toEqual(Buffer.from('content'));
38
38
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
39
39
  });
40
40
  });
41
41
 
42
- describe("when properties are passed", () => {
43
- it("should return a buffer", async () => {
42
+ describe('when properties are passed', () => {
43
+ it('should return a buffer', async () => {
44
44
  mockPromisesAccess.mockResolvedValue();
45
- mockFetch.mockResolvedValue(new Response("content"));
45
+ mockFetch.mockResolvedValue(new Response('content'));
46
46
  const buffer = await PDFEngine.convert({
47
- files: ["path/to/file.docx", "path/to/file.bib"],
48
- properties: {landscape: true},
47
+ files: ['path/to/file.docx', 'path/to/file.bib'],
48
+ properties: { landscape: true },
49
49
  pdfFormat: PdfFormat.A_1a,
50
50
  pdfUA: true,
51
- merge: true,
51
+ merge: true
52
52
  });
53
- expect(buffer).toEqual(Buffer.from("content"));
53
+ expect(buffer).toEqual(Buffer.from('content'));
54
54
  expect(mockFormDataAppend).toHaveBeenCalledTimes(6);
55
55
  });
56
56
  });
57
57
  });
58
58
 
59
- describe("merge", () => {
60
- it("should return a buffer", async () => {
59
+ describe('merge', () => {
60
+ it('should return a buffer', async () => {
61
61
  mockPromisesAccess.mockResolvedValue();
62
- mockFetch.mockResolvedValue(new Response("content"));
62
+ mockFetch.mockResolvedValue(new Response('content'));
63
63
  const buffer = await PDFEngine.merge({
64
- files: ["path/to/file.pdf", "path/to/another-file.pdf"],
64
+ files: ['path/to/file.pdf', 'path/to/another-file.pdf']
65
65
  });
66
- expect(buffer).toEqual(Buffer.from("content"));
66
+ expect(buffer).toEqual(Buffer.from('content'));
67
67
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
68
68
  });
69
69
  });
70
70
 
71
- describe("generate", () => {
72
- const mockFilename = "test.pdf";
73
- const mockBuffer = Buffer.from("mock pdf content");
71
+ describe('generate', () => {
72
+ const mockFilename = 'test.pdf';
73
+ const mockBuffer = Buffer.from('mock pdf content');
74
74
 
75
75
  afterAll(() => {
76
76
  jest.restoreAllMocks();
77
77
  });
78
78
 
79
- it("should generate a PDF file", async () => {
80
- const mockGeneratedDir = path.join(process.cwd(), "__generated__");
81
- const mockGeneratedFilePath = path.join(mockGeneratedDir, mockFilename);
79
+ it('should generate a PDF file', async () => {
80
+ const mockGeneratedDir = path.join(process.cwd(), '__generated__');
81
+ const mockGeneratedFilePath = path.join(
82
+ mockGeneratedDir,
83
+ mockFilename
84
+ );
82
85
 
83
86
  const mockPromisesMkDir = jest
84
- .spyOn(fs, "mkdir")
87
+ .spyOn(fs, 'mkdir')
85
88
  .mockResolvedValueOnce(mockGeneratedDir);
86
89
 
87
90
  const mockPromisesWriteFile = jest
88
- .spyOn(fs, "writeFile")
91
+ .spyOn(fs, 'writeFile')
89
92
  .mockResolvedValueOnce();
90
93
 
91
94
  await PDFEngine.generate(mockFilename, mockBuffer);
92
95
 
93
96
  expect(mockPromisesMkDir).toHaveBeenCalledWith(mockGeneratedDir, {
94
- recursive: true,
97
+ recursive: true
95
98
  });
96
99
 
97
100
  expect(mockPromisesWriteFile).toHaveBeenCalledWith(
@@ -100,24 +103,24 @@ describe("PDFEngine", () => {
100
103
  );
101
104
  });
102
105
 
103
- it("should handle errors during file generation", async () => {
104
- jest
105
- .spyOn(fs, "mkdir")
106
- .mockRejectedValueOnce(new Error("Cannot create directory"));
106
+ it('should handle errors during file generation', async () => {
107
+ jest.spyOn(fs, 'mkdir').mockRejectedValueOnce(
108
+ new Error('Cannot create directory')
109
+ );
107
110
 
108
111
  await expect(
109
112
  PDFEngine.generate(mockFilename, mockBuffer)
110
- ).rejects.toThrow("Cannot create directory");
113
+ ).rejects.toThrow('Cannot create directory');
111
114
  });
112
115
 
113
- it("should handle errors during file writing", async () => {
114
- jest
115
- .spyOn(fs, "writeFile")
116
- .mockRejectedValueOnce(new Error("Failed to write to file"));
116
+ it('should handle errors during file writing', async () => {
117
+ jest.spyOn(fs, 'writeFile').mockRejectedValueOnce(
118
+ new Error('Failed to write to file')
119
+ );
117
120
 
118
121
  await expect(
119
122
  PDFEngine.generate(mockFilename, mockBuffer)
120
- ).rejects.toThrow("Failed to write to file");
123
+ ).rejects.toThrow('Failed to write to file');
121
124
  });
122
125
  });
123
126
  });
@@ -1,8 +1,8 @@
1
- import {constants, createReadStream, promises, ReadStream} from "fs";
2
- import path from "path";
1
+ import { constants, createReadStream, promises, ReadStream } from 'fs';
2
+ import path from 'path';
3
3
 
4
- import FormData from "form-data";
5
- import {PathLikeOrReadStream} from "../../common";
4
+ import FormData from 'form-data';
5
+ import { PathLikeOrReadStream } from '../../common';
6
6
 
7
7
  /**
8
8
  * Utility class for handling common tasks related to PDF engine operations.
@@ -15,18 +15,21 @@ export class PDFEngineUtils {
15
15
  * @param {FormData} data - The FormData object to which PDF files will be added.
16
16
  * @throws {Error} Throws an error if the file extension is not supported.
17
17
  */
18
- public static async addFiles(files: PathLikeOrReadStream[], data: FormData) {
18
+ public static async addFiles(
19
+ files: PathLikeOrReadStream[],
20
+ data: FormData
21
+ ) {
19
22
  for (const [key, file] of files.entries()) {
20
- const filename = `file${key}.pdf`
23
+ const filename = `file${key}.pdf`;
21
24
  if (Buffer.isBuffer(file)) {
22
- data.append("files", file, filename);
25
+ data.append('files', file, filename);
23
26
  } else if (file instanceof ReadStream) {
24
- data.append("files", file, filename);
27
+ data.append('files', file, filename);
25
28
  } else {
26
29
  await promises.access(file, constants.R_OK);
27
30
  const filename = path.basename(file.toString());
28
31
  const extension = path.extname(filename);
29
- if (extension === ".pdf") {
32
+ if (extension === '.pdf') {
30
33
  data.append(filename, createReadStream(file));
31
34
  } else {
32
35
  throw new Error(`${extension} is not supported`);
@@ -1,12 +1,12 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- import {createReadStream, promises} from "fs";
3
- import FormData from "form-data";
2
+ import { createReadStream, promises } from 'fs';
3
+ import FormData from 'form-data';
4
4
 
5
- import {PDFEngineUtils} from "../engine.utils";
5
+ import { PDFEngineUtils } from '../engine.utils';
6
6
 
7
- describe("PDFEngineUtils", () => {
8
- const mockPromisesAccess = jest.spyOn(promises, "access");
9
- const mockFormDataAppend = jest.spyOn(FormData.prototype, "append");
7
+ describe('PDFEngineUtils', () => {
8
+ const mockPromisesAccess = jest.spyOn(promises, 'access');
9
+ const mockFormDataAppend = jest.spyOn(FormData.prototype, 'append');
10
10
  const data = new FormData();
11
11
 
12
12
  beforeEach(() => {
@@ -19,50 +19,50 @@ describe("PDFEngineUtils", () => {
19
19
  jest.resetAllMocks();
20
20
  });
21
21
 
22
- describe("addFiles", () => {
23
- describe("when files exist", () => {
24
- describe("when files parameter contains paths", () => {
25
- it("should append each file to data", async () => {
22
+ describe('addFiles', () => {
23
+ describe('when files exist', () => {
24
+ describe('when files parameter contains paths', () => {
25
+ it('should append each file to data', async () => {
26
26
  mockPromisesAccess.mockResolvedValue();
27
27
  await PDFEngineUtils.addFiles(
28
- ["path/to/file.pdf", "path/to/another-file.pdf"],
28
+ ['path/to/file.pdf', 'path/to/another-file.pdf'],
29
29
  data
30
30
  );
31
31
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
32
32
  });
33
- })
34
- describe("when files parameter contains a buffer", () => {
35
- it("should append each file to data", async () => {
33
+ });
34
+ describe('when files parameter contains a buffer', () => {
35
+ it('should append each file to data', async () => {
36
36
  mockPromisesAccess.mockResolvedValue();
37
37
  await PDFEngineUtils.addFiles(
38
- [Buffer.from("data"), "path/to/another-file.pdf"],
38
+ [Buffer.from('data'), 'path/to/another-file.pdf'],
39
39
  data
40
40
  );
41
41
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
42
42
  });
43
- })
43
+ });
44
44
  });
45
45
 
46
- describe("when one of the files is not PDF", () => {
47
- it("should throw an error", async () => {
46
+ describe('when one of the files is not PDF', () => {
47
+ it('should throw an error', async () => {
48
48
  mockPromisesAccess.mockResolvedValue();
49
49
  await expect(() =>
50
50
  PDFEngineUtils.addFiles(
51
- ["path/to/file.docx", "path/to/file.pdf"],
51
+ ['path/to/file.docx', 'path/to/file.pdf'],
52
52
  data
53
53
  )
54
- ).rejects.toThrow(".docx is not supported");
54
+ ).rejects.toThrow('.docx is not supported');
55
55
  });
56
56
  });
57
57
 
58
- describe("when one of the files does not exist", () => {
59
- it("should throw an error", async () => {
58
+ describe('when one of the files does not exist', () => {
59
+ it('should throw an error', async () => {
60
60
  const errorMessage =
61
61
  "ENOENT: no such file or directory, access 'path/to/index.html'";
62
62
  mockPromisesAccess.mockRejectedValue(new Error(errorMessage));
63
63
  await expect(() =>
64
64
  PDFEngineUtils.addFiles(
65
- ["path/to/file.pdf", "path/to/another-file.pdf"],
65
+ ['path/to/file.pdf', 'path/to/another-file.pdf'],
66
66
  data
67
67
  )
68
68
  ).rejects.toThrow(errorMessage);