chromiumly 2.5.1 → 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 +13 -4
  6. package/dist/chromium/converters/html.converter.js +9 -2
  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 +25 -17
  52. package/src/.prettierrc.yml +4 -0
  53. package/src/chromium/converters/converter.ts +2 -2
  54. package/src/chromium/converters/html.converter.ts +40 -24
  55. package/src/chromium/converters/markdown.converter.ts +32 -26
  56. package/src/chromium/converters/tests/html.converter.test.ts +111 -68
  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,360 +1,430 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- import {createReadStream, promises} from "fs";
3
- import path from "path";
4
- import FormData from "form-data";
5
- import {ConverterUtils} from "../converter.utils";
6
- import {PdfFormat} from "../../../common";
7
-
8
- describe("ConverterUtils", () => {
9
- const mockFormDataAppend = jest.spyOn(FormData.prototype, "append");
2
+ import { createReadStream, promises } from 'fs';
3
+ import path from 'path';
4
+ import FormData from 'form-data';
5
+ import { ConverterUtils } from '../converter.utils';
6
+ import { GotenbergUtils, PdfFormat } from '../../../common';
7
+
8
+ describe('GotenbergUtils', () => {
9
+ const mockFormDataAppend = jest.spyOn(FormData.prototype, 'append');
10
10
  const data = new FormData();
11
11
 
12
12
  afterEach(() => {
13
13
  jest.resetAllMocks();
14
14
  });
15
15
 
16
- describe("addPageProperties", () => {
17
- describe("Page size", () => {
18
- describe("when page size is valid", () => {
19
- it("should append page size to data", () => {
16
+ describe('addPageProperties', () => {
17
+ describe('Single page', () => {
18
+ describe('when singlePage parameter is set', () => {
19
+ it('should append singlePage to data', () => {
20
20
  ConverterUtils.addPageProperties(data, {
21
- size: {width: 8.3, height: 11.7},
21
+ singlePage: true
22
+ });
23
+ expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
24
+ expect(data.append).toHaveBeenCalledWith(
25
+ 'singlePage',
26
+ 'true'
27
+ );
28
+ });
29
+ });
30
+ });
31
+
32
+ describe('Page size', () => {
33
+ describe('when page size is valid', () => {
34
+ it('should append page size to data', () => {
35
+ ConverterUtils.addPageProperties(data, {
36
+ size: { width: 8.3, height: 11.7 }
22
37
  });
23
38
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
24
- expect(data.append).toHaveBeenCalledWith("paperWidth", 8.3);
25
- expect(data.append).toHaveBeenNthCalledWith(2, "paperHeight", 11.7);
39
+ expect(data.append).toHaveBeenCalledWith('paperWidth', 8.3);
40
+ expect(data.append).toHaveBeenNthCalledWith(
41
+ 2,
42
+ 'paperHeight',
43
+ 11.7
44
+ );
26
45
  });
27
46
  });
28
47
  });
29
48
 
30
- describe("Page margins", () => {
31
- describe("when page margins are valid", () => {
32
- it("should append page margins to data", () => {
49
+ describe('Page margins', () => {
50
+ describe('when page margins are valid', () => {
51
+ it('should append page margins to data', () => {
33
52
  ConverterUtils.addPageProperties(data, {
34
- margins: {top: 0.5, bottom: 0.5, left: 1, right: 1},
53
+ margins: { top: 0.5, bottom: 0.5, left: 1, right: 1 }
35
54
  });
36
55
  expect(mockFormDataAppend).toHaveBeenCalledTimes(4);
37
- expect(data.append).toHaveBeenCalledWith("marginTop", 0.5);
38
- expect(data.append).toHaveBeenNthCalledWith(2, "marginBottom", 0.5);
39
- expect(data.append).toHaveBeenNthCalledWith(3, "marginLeft", 1);
40
- expect(data.append).toHaveBeenNthCalledWith(4, "marginRight", 1);
56
+ expect(data.append).toHaveBeenCalledWith('marginTop', 0.5);
57
+ expect(data.append).toHaveBeenNthCalledWith(
58
+ 2,
59
+ 'marginBottom',
60
+ 0.5
61
+ );
62
+ expect(data.append).toHaveBeenNthCalledWith(
63
+ 3,
64
+ 'marginLeft',
65
+ 1
66
+ );
67
+ expect(data.append).toHaveBeenNthCalledWith(
68
+ 4,
69
+ 'marginRight',
70
+ 1
71
+ );
41
72
  });
42
73
  });
43
74
  });
44
75
 
45
- describe("Page css size", () => {
46
- describe("when preferCssPageSize parameter is set", () => {
47
- it("should append preferCssPageSize to data", () => {
76
+ describe('Page css size', () => {
77
+ describe('when preferCssPageSize parameter is set', () => {
78
+ it('should append preferCssPageSize to data', () => {
48
79
  ConverterUtils.addPageProperties(data, {
49
- preferCssPageSize: true,
80
+ preferCssPageSize: true
50
81
  });
51
82
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
52
- expect(data.append).toHaveBeenCalledWith("preferCssPageSize", "true");
83
+ expect(data.append).toHaveBeenCalledWith(
84
+ 'preferCssPageSize',
85
+ 'true'
86
+ );
53
87
  });
54
88
  });
55
89
  });
56
90
 
57
- describe("Page background", () => {
58
- describe("when printBackground parameter is set", () => {
59
- it("should append printBackground to data", () => {
91
+ describe('Page background', () => {
92
+ describe('when printBackground parameter is set', () => {
93
+ it('should append printBackground to data', () => {
60
94
  ConverterUtils.addPageProperties(data, {
61
- printBackground: true,
95
+ printBackground: true
62
96
  });
63
97
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
64
- expect(data.append).toHaveBeenCalledWith("printBackground", "true");
98
+ expect(data.append).toHaveBeenCalledWith(
99
+ 'printBackground',
100
+ 'true'
101
+ );
65
102
  });
66
103
  });
67
104
 
68
- describe("when omitBackground parameter is set", () => {
69
- it("should append omitBackground to data", () => {
105
+ describe('when omitBackground parameter is set', () => {
106
+ it('should append omitBackground to data', () => {
70
107
  ConverterUtils.addPageProperties(data, {
71
- omitBackground: true,
108
+ omitBackground: true
72
109
  });
73
110
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
74
- expect(data.append).toHaveBeenCalledWith("omitBackground", "true");
111
+ expect(data.append).toHaveBeenCalledWith(
112
+ 'omitBackground',
113
+ 'true'
114
+ );
75
115
  });
76
116
  });
77
117
  });
78
118
 
79
- describe("Page landscape", () => {
80
- describe("when landscape parameter is set", () => {
81
- it("should append landscape to data", () => {
119
+ describe('Page landscape', () => {
120
+ describe('when landscape parameter is set', () => {
121
+ it('should append landscape to data', () => {
82
122
  ConverterUtils.addPageProperties(data, {
83
- landscape: true,
123
+ landscape: true
84
124
  });
85
125
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
86
- expect(data.append).toHaveBeenCalledWith("landscape", "true");
126
+ expect(data.append).toHaveBeenCalledWith(
127
+ 'landscape',
128
+ 'true'
129
+ );
87
130
  });
88
131
  });
89
132
  });
90
133
 
91
- describe("Page scale", () => {
92
- describe("when page scale is valid", () => {
93
- it("should append scale to data", () => {
134
+ describe('Page scale', () => {
135
+ describe('when page scale is valid', () => {
136
+ it('should append scale to data', () => {
94
137
  ConverterUtils.addPageProperties(data, {
95
- scale: 1.5,
138
+ scale: 1.5
96
139
  });
97
140
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
98
- expect(data.append).toHaveBeenCalledWith("scale", 1.5);
141
+ expect(data.append).toHaveBeenCalledWith('scale', 1.5);
99
142
  });
100
143
  });
101
144
  });
102
145
 
103
- describe("Page ranges", () => {
104
- describe("when nativePageRanges is valid", () => {
105
- it("should append nativePageRanges to data", () => {
146
+ describe('Page ranges', () => {
147
+ describe('when nativePageRanges is valid', () => {
148
+ it('should append nativePageRanges to data', () => {
106
149
  ConverterUtils.addPageProperties(data, {
107
- nativePageRanges: {from: 1, to: 6},
150
+ nativePageRanges: { from: 1, to: 6 }
108
151
  });
109
152
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
110
- expect(data.append).toHaveBeenCalledWith("nativePageRanges", "1-6");
153
+ expect(data.append).toHaveBeenCalledWith(
154
+ 'nativePageRanges',
155
+ '1-6'
156
+ );
111
157
  });
112
158
  });
113
159
  });
114
160
  });
115
161
 
116
- describe("addFile", () => {
117
- const __tmp__ = path.resolve(process.cwd(), "__tmp__");
118
- const filePath = path.resolve(__tmp__, "file.html")
162
+ describe('addFile', () => {
163
+ const __tmp__ = path.resolve(process.cwd(), '__tmp__');
164
+ const filePath = path.resolve(__tmp__, 'file.html');
119
165
 
120
166
  beforeAll(async () => {
121
- await promises.mkdir(path.resolve(__tmp__), {recursive: true});
122
- await promises.writeFile(filePath, "data");
123
- })
167
+ await promises.mkdir(path.resolve(__tmp__), { recursive: true });
168
+ await promises.writeFile(filePath, 'data');
169
+ });
124
170
 
125
171
  afterAll(async () => {
126
- await promises.rm(path.resolve(__tmp__), {recursive: true})
127
- })
172
+ await promises.rm(path.resolve(__tmp__), { recursive: true });
173
+ });
128
174
 
129
- describe("when file is passed as read stream", () => {
130
- it("should append file to data", async () => {
131
- const file = createReadStream(filePath)
132
- await ConverterUtils.addFile(data, file, "file");
175
+ describe('when file is passed as read stream', () => {
176
+ it('should append file to data', async () => {
177
+ const file = createReadStream(filePath);
178
+ await GotenbergUtils.addFile(data, file, 'file');
133
179
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
134
- expect(data.append).toHaveBeenCalledWith("files", file, "file");
135
- })
136
- })
180
+ expect(data.append).toHaveBeenCalledWith('files', file, 'file');
181
+ });
182
+ });
137
183
 
138
- describe("when file is passed as path", () => {
139
- it("should append file to data", async () => {
140
- await ConverterUtils.addFile(data, filePath, "file");
184
+ describe('when file is passed as path', () => {
185
+ it('should append file to data', async () => {
186
+ await GotenbergUtils.addFile(data, filePath, 'file');
141
187
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
142
- })
143
- })
188
+ });
189
+ });
144
190
 
145
- describe("when file is passed as buffer", () => {
146
- it("should append file to data", async () => {
147
- const file = Buffer.from("data")
148
- await ConverterUtils.addFile(data, file, "file");
191
+ describe('when file is passed as buffer', () => {
192
+ it('should append file to data', async () => {
193
+ const file = Buffer.from('data');
194
+ await GotenbergUtils.addFile(data, file, 'file');
149
195
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
150
- expect(data.append).toHaveBeenCalledWith("files", file, "file");
151
- })
152
- })
153
-
154
-
155
- })
196
+ expect(data.append).toHaveBeenCalledWith('files', file, 'file');
197
+ });
198
+ });
199
+ });
156
200
 
157
- describe("customize", () => {
158
- describe("when no option is passed", () => {
159
- it("should not append anything", async () => {
201
+ describe('customize', () => {
202
+ describe('when no option is passed', () => {
203
+ it('should not append anything', async () => {
160
204
  await ConverterUtils.customize(data, {});
161
205
  expect(mockFormDataAppend).toHaveBeenCalledTimes(0);
162
206
  });
163
207
  });
164
208
 
165
- describe("when header parameter is passed", () => {
166
- it("should append header", async () => {
209
+ describe('when header parameter is passed', () => {
210
+ it('should append header', async () => {
167
211
  await ConverterUtils.customize(data, {
168
- header: Buffer.from("header"),
212
+ header: Buffer.from('header')
169
213
  });
170
214
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
171
215
  expect(data.append).toHaveBeenCalledWith(
172
- "files",
173
- Buffer.from("header"),
174
- "header.html"
216
+ 'files',
217
+ Buffer.from('header'),
218
+ 'header.html'
175
219
  );
176
220
  });
177
221
  });
178
222
 
179
- describe("when footer parameter is passed", () => {
180
- it("should append footer", async () => {
223
+ describe('when footer parameter is passed', () => {
224
+ it('should append footer', async () => {
181
225
  await ConverterUtils.customize(data, {
182
- footer: Buffer.from("footer"),
226
+ footer: Buffer.from('footer')
183
227
  });
184
228
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
185
229
  expect(data.append).toHaveBeenCalledWith(
186
- "files",
187
- Buffer.from("footer"),
188
- "footer.html"
230
+ 'files',
231
+ Buffer.from('footer'),
232
+ 'footer.html'
189
233
  );
190
234
  });
191
235
  });
192
236
 
193
- describe("when pdf format parameter is passed", () => {
194
- it("should append pdf format", async () => {
237
+ describe('when pdf format parameter is passed', () => {
238
+ it('should append pdf format', async () => {
195
239
  await ConverterUtils.customize(data, {
196
- pdfFormat: PdfFormat.A_1a,
240
+ pdfFormat: PdfFormat.A_1a
197
241
  });
198
242
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
199
- expect(data.append).toHaveBeenCalledWith("pdfa", "PDF/A-1a");
243
+ expect(data.append).toHaveBeenCalledWith('pdfa', 'PDF/A-1a');
200
244
  });
201
245
  });
202
246
 
203
- describe("when pdf universal access parameter is passed", () => {
204
- it("should append pdfua format", async () => {
247
+ describe('when pdf universal access parameter is passed', () => {
248
+ it('should append pdfua format', async () => {
205
249
  await ConverterUtils.customize(data, {
206
- pdfUA: true,
250
+ pdfUA: true
207
251
  });
208
252
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
209
- expect(data.append).toHaveBeenCalledWith("pdfua", "true");
253
+ expect(data.append).toHaveBeenCalledWith('pdfua', 'true');
210
254
  });
211
255
  });
212
256
 
213
- describe("when page properties parameter is passed", () => {
214
- it("should append page propertiers", async () => {
257
+ describe('when page properties parameter is passed', () => {
258
+ it('should append page propertiers', async () => {
215
259
  await ConverterUtils.customize(data, {
216
- properties: {size: {width: 8.3, height: 11.7}},
260
+ properties: { size: { width: 8.3, height: 11.7 } }
217
261
  });
218
262
  expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
219
- expect(data.append).toHaveBeenCalledWith("paperWidth", 8.3);
220
- expect(data.append).toHaveBeenNthCalledWith(2, "paperHeight", 11.7);
263
+ expect(data.append).toHaveBeenCalledWith('paperWidth', 8.3);
264
+ expect(data.append).toHaveBeenNthCalledWith(
265
+ 2,
266
+ 'paperHeight',
267
+ 11.7
268
+ );
221
269
  });
222
270
  });
223
271
 
224
- describe("when emulatedMediaType parameter is passed", () => {
225
- it("should append emulatedMediaType", async () => {
272
+ describe('when emulatedMediaType parameter is passed', () => {
273
+ it('should append emulatedMediaType', async () => {
226
274
  await ConverterUtils.customize(data, {
227
- emulatedMediaType: "screen",
275
+ emulatedMediaType: 'screen'
228
276
  });
229
277
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
230
- expect(data.append).toHaveBeenCalledWith("emulatedMediaType", "screen");
278
+ expect(data.append).toHaveBeenCalledWith(
279
+ 'emulatedMediaType',
280
+ 'screen'
281
+ );
231
282
  });
232
283
  });
233
284
 
234
- describe("when waitDelay parameter is passed", () => {
235
- it("should append waitDelay", async () => {
285
+ describe('when waitDelay parameter is passed', () => {
286
+ it('should append waitDelay', async () => {
236
287
  await ConverterUtils.customize(data, {
237
- waitDelay: "5s",
288
+ waitDelay: '5s'
238
289
  });
239
290
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
240
- expect(data.append).toHaveBeenCalledWith("waitDelay", "5s");
291
+ expect(data.append).toHaveBeenCalledWith('waitDelay', '5s');
241
292
  });
242
293
  });
243
294
 
244
- describe("when waitForExpression parameter is passed", () => {
245
- it("should append waitForExpression", async () => {
295
+ describe('when waitForExpression parameter is passed', () => {
296
+ it('should append waitForExpression', async () => {
246
297
  await ConverterUtils.customize(data, {
247
- waitForExpression: "document.readyState === 'complete'",
298
+ waitForExpression: "document.readyState === 'complete'"
248
299
  });
249
300
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
250
301
  expect(data.append).toHaveBeenCalledWith(
251
- "waitForExpression",
302
+ 'waitForExpression',
252
303
  "document.readyState === 'complete'"
253
304
  );
254
305
  });
255
306
  });
256
307
 
257
- describe("when userAgent parameter is passed", () => {
258
- it("should append userAgent", async () => {
308
+ describe('when userAgent parameter is passed', () => {
309
+ it('should append userAgent', async () => {
259
310
  const userAgent =
260
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
311
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36';
261
312
 
262
313
  await ConverterUtils.customize(data, {
263
- userAgent,
314
+ userAgent
264
315
  });
265
316
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
266
- expect(data.append).toHaveBeenCalledWith("userAgent", userAgent);
317
+ expect(data.append).toHaveBeenCalledWith(
318
+ 'userAgent',
319
+ userAgent
320
+ );
267
321
  });
268
322
  });
269
323
 
270
- describe("when extraHttpHeaders parameter is passed", () => {
271
- it("should append extraHttpHeaders", async () => {
324
+ describe('when extraHttpHeaders parameter is passed', () => {
325
+ it('should append extraHttpHeaders', async () => {
272
326
  const extraHttpHeaders = {
273
- "X-Custom-Header": "value",
327
+ 'X-Custom-Header': 'value'
274
328
  };
275
329
 
276
330
  await ConverterUtils.customize(data, {
277
- extraHttpHeaders,
331
+ extraHttpHeaders
278
332
  });
279
333
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
280
334
  expect(data.append).toHaveBeenCalledWith(
281
- "extraHttpHeaders",
335
+ 'extraHttpHeaders',
282
336
  JSON.stringify(extraHttpHeaders)
283
337
  );
284
338
  });
285
339
  });
286
340
 
287
- describe("when failOnConsoleExceptions parameter is passed", () => {
288
- it("should append failOnConsoleExceptions", async () => {
341
+ describe('when failOnConsoleExceptions parameter is passed', () => {
342
+ it('should append failOnConsoleExceptions', async () => {
289
343
  await ConverterUtils.customize(data, {
290
- failOnConsoleExceptions: true,
344
+ failOnConsoleExceptions: true
291
345
  });
292
346
  expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
293
347
  expect(data.append).toHaveBeenCalledWith(
294
- "failOnConsoleExceptions",
295
- "true"
348
+ 'failOnConsoleExceptions',
349
+ 'true'
296
350
  );
297
351
  });
298
352
  });
299
353
 
300
- describe("when all options are passed", () => {
301
- it("should append all options", async () => {
354
+ describe('when all options are passed', () => {
355
+ it('should append all options', async () => {
302
356
  await ConverterUtils.customize(data, {
303
- header: Buffer.from("header.html"),
304
- footer: Buffer.from("footer.html"),
357
+ header: Buffer.from('header.html'),
358
+ footer: Buffer.from('footer.html'),
305
359
  pdfFormat: PdfFormat.A_1a,
306
360
  pdfUA: true,
307
- emulatedMediaType: "screen",
308
- properties: {size: {width: 8.3, height: 11.7}},
309
- waitDelay: "5s",
361
+ emulatedMediaType: 'screen',
362
+ properties: { size: { width: 8.3, height: 11.7 } },
363
+ waitDelay: '5s',
310
364
  waitForExpression: "document.readyState === 'complete'",
311
365
  userAgent:
312
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
313
- extraHttpHeaders: {"X-Custom-Header": "value"},
314
- failOnConsoleExceptions: true,
366
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
367
+ extraHttpHeaders: { 'X-Custom-Header': 'value' },
368
+ failOnConsoleExceptions: true
315
369
  });
316
370
  expect(mockFormDataAppend).toHaveBeenCalledTimes(12);
317
- expect(data.append).toHaveBeenNthCalledWith(1, "pdfa", "PDF/A-1a");
318
- expect(data.append).toHaveBeenNthCalledWith(2, "pdfua", "true");
371
+ expect(data.append).toHaveBeenNthCalledWith(
372
+ 1,
373
+ 'pdfa',
374
+ 'PDF/A-1a'
375
+ );
376
+ expect(data.append).toHaveBeenNthCalledWith(2, 'pdfua', 'true');
319
377
  expect(data.append).toHaveBeenNthCalledWith(
320
378
  3,
321
- "files",
322
- Buffer.from("header.html"),
323
- "header.html"
379
+ 'files',
380
+ Buffer.from('header.html'),
381
+ 'header.html'
324
382
  );
325
383
  expect(data.append).toHaveBeenNthCalledWith(
326
384
  4,
327
- "files",
328
- Buffer.from("footer.html"),
329
- "footer.html"
385
+ 'files',
386
+ Buffer.from('footer.html'),
387
+ 'footer.html'
330
388
  );
331
389
  expect(data.append).toHaveBeenNthCalledWith(
332
390
  5,
333
- "emulatedMediaType",
334
- "screen"
391
+ 'emulatedMediaType',
392
+ 'screen'
393
+ );
394
+ expect(data.append).toHaveBeenNthCalledWith(
395
+ 6,
396
+ 'paperWidth',
397
+ 8.3
398
+ );
399
+ expect(data.append).toHaveBeenNthCalledWith(
400
+ 7,
401
+ 'paperHeight',
402
+ 11.7
403
+ );
404
+ expect(data.append).toHaveBeenNthCalledWith(
405
+ 8,
406
+ 'waitDelay',
407
+ '5s'
335
408
  );
336
- expect(data.append).toHaveBeenNthCalledWith(6, "paperWidth", 8.3);
337
- expect(data.append).toHaveBeenNthCalledWith(7, "paperHeight", 11.7);
338
- expect(data.append).toHaveBeenNthCalledWith(8, "waitDelay", "5s");
339
409
  expect(data.append).toHaveBeenNthCalledWith(
340
410
  9,
341
- "waitForExpression",
411
+ 'waitForExpression',
342
412
  "document.readyState === 'complete'"
343
413
  );
344
414
  expect(data.append).toHaveBeenNthCalledWith(
345
415
  10,
346
- "userAgent",
347
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
416
+ 'userAgent',
417
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
348
418
  );
349
419
  expect(data.append).toHaveBeenNthCalledWith(
350
420
  11,
351
- "extraHttpHeaders",
352
- JSON.stringify({"X-Custom-Header": "value"})
421
+ 'extraHttpHeaders',
422
+ JSON.stringify({ 'X-Custom-Header': 'value' })
353
423
  );
354
424
  expect(data.append).toHaveBeenNthCalledWith(
355
425
  12,
356
- "failOnConsoleExceptions",
357
- "true"
426
+ 'failOnConsoleExceptions',
427
+ 'true'
358
428
  );
359
429
  });
360
430
  });
@@ -1,5 +1,5 @@
1
1
  export enum PdfFormat {
2
- A_1a = "PDF/A-1a",
3
- A_2b = "PDF/A-2b",
4
- A_3b = "PDF/A-3b",
2
+ A_1a = 'PDF/A-1a',
3
+ A_2b = 'PDF/A-2b',
4
+ A_3b = 'PDF/A-3b'
5
5
  }