pdf-oxide 0.3.24

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 (62) hide show
  1. package/README.md +218 -0
  2. package/binding.gyp +35 -0
  3. package/package.json +78 -0
  4. package/src/builders/annotation-builder.ts +367 -0
  5. package/src/builders/conversion-options-builder.ts +257 -0
  6. package/src/builders/index.ts +12 -0
  7. package/src/builders/metadata-builder.ts +317 -0
  8. package/src/builders/pdf-builder.ts +386 -0
  9. package/src/builders/search-options-builder.ts +151 -0
  10. package/src/document-editor-manager.ts +318 -0
  11. package/src/errors.ts +1629 -0
  12. package/src/form-field-manager.ts +666 -0
  13. package/src/hybrid-ml-manager.ts +283 -0
  14. package/src/index.ts +453 -0
  15. package/src/managers/accessibility-manager.ts +338 -0
  16. package/src/managers/annotation-manager.ts +439 -0
  17. package/src/managers/barcode-manager.ts +235 -0
  18. package/src/managers/batch-manager.ts +533 -0
  19. package/src/managers/cache-manager.ts +486 -0
  20. package/src/managers/compliance-manager.ts +375 -0
  21. package/src/managers/content-manager.ts +339 -0
  22. package/src/managers/document-utility-manager.ts +922 -0
  23. package/src/managers/dom-pdf-creator.ts +365 -0
  24. package/src/managers/editing-manager.ts +514 -0
  25. package/src/managers/enterprise-manager.ts +478 -0
  26. package/src/managers/extended-managers.ts +437 -0
  27. package/src/managers/extraction-manager.ts +583 -0
  28. package/src/managers/final-utilities.ts +429 -0
  29. package/src/managers/hybrid-ml-advanced.ts +479 -0
  30. package/src/managers/index.ts +239 -0
  31. package/src/managers/layer-manager.ts +500 -0
  32. package/src/managers/metadata-manager.ts +303 -0
  33. package/src/managers/ocr-manager.ts +756 -0
  34. package/src/managers/optimization-manager.ts +262 -0
  35. package/src/managers/outline-manager.ts +196 -0
  36. package/src/managers/page-manager.ts +289 -0
  37. package/src/managers/pattern-detection.ts +440 -0
  38. package/src/managers/rendering-manager.ts +863 -0
  39. package/src/managers/search-manager.ts +385 -0
  40. package/src/managers/security-manager.ts +345 -0
  41. package/src/managers/signature-manager.ts +1664 -0
  42. package/src/managers/streams.ts +618 -0
  43. package/src/managers/xfa-manager.ts +500 -0
  44. package/src/pdf-creator-manager.ts +494 -0
  45. package/src/properties.ts +522 -0
  46. package/src/result-accessors-manager.ts +867 -0
  47. package/src/tests/advanced-features.test.ts +414 -0
  48. package/src/tests/advanced.test.ts +266 -0
  49. package/src/tests/extended-managers.test.ts +316 -0
  50. package/src/tests/final-utilities.test.ts +455 -0
  51. package/src/tests/foundation.test.ts +315 -0
  52. package/src/tests/high-demand.test.ts +257 -0
  53. package/src/tests/specialized.test.ts +97 -0
  54. package/src/thumbnail-manager.ts +272 -0
  55. package/src/types/common.ts +142 -0
  56. package/src/types/document-types.ts +457 -0
  57. package/src/types/index.ts +6 -0
  58. package/src/types/manager-types.ts +284 -0
  59. package/src/types/native-bindings.ts +517 -0
  60. package/src/workers/index.ts +7 -0
  61. package/src/workers/pool.ts +274 -0
  62. package/src/workers/worker.ts +131 -0
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Comprehensive test suite for Phase 1 Foundation.
3
+ * Tests: ResultAccessorsManager, FormFieldManager
4
+ */
5
+
6
+ import { describe, it, expect, beforeEach } from '@jest/globals';
7
+
8
+ import FormFieldManager from '../managers/form-field-manager';
9
+ import ResultAccessorsManager from '../managers/result-accessors-manager';
10
+
11
+ describe('Phase 1 Foundation', () => {
12
+ describe('ResultAccessorsManager', () => {
13
+ let manager: ResultAccessorsManager;
14
+
15
+ beforeEach(() => {
16
+ manager = new ResultAccessorsManager();
17
+ });
18
+
19
+ it('should get result status as string or null', () => {
20
+ const result = manager.getResultStatus();
21
+ expect(result === null || typeof result === 'string').toBe(true);
22
+ });
23
+
24
+ it('should check result success and return boolean', () => {
25
+ const result = manager.isResultSuccess();
26
+ expect(typeof result).toBe('boolean');
27
+ });
28
+
29
+ it('should check result error and return boolean', () => {
30
+ const result = manager.isResultError();
31
+ expect(typeof result).toBe('boolean');
32
+ });
33
+
34
+ it('should get error message as string or null', () => {
35
+ const result = manager.getErrorMessage();
36
+ expect(result === null || typeof result === 'string').toBe(true);
37
+ });
38
+
39
+ it('should get error code as int/string or null', () => {
40
+ const result = manager.getErrorCode();
41
+ expect(result === null || typeof result === 'number' || typeof result === 'string').toBe(true);
42
+ });
43
+
44
+ it('should check if has error details', () => {
45
+ const result = manager.hasErrorDetails();
46
+ expect(typeof result).toBe('boolean');
47
+ });
48
+
49
+ it('should get error details as object or null', () => {
50
+ const result = manager.getErrorDetails();
51
+ expect(result === null || typeof result === 'object').toBe(true);
52
+ });
53
+
54
+ it('should get result data of various types', () => {
55
+ const result = manager.getResultData();
56
+ expect(result === null || typeof result === 'object' || typeof result === 'string' ||
57
+ typeof result === 'number').toBe(true);
58
+ });
59
+
60
+ it('should get result metadata as object or null', () => {
61
+ const result = manager.getResultMetadata();
62
+ expect(result === null || typeof result === 'object').toBe(true);
63
+ });
64
+
65
+ it('should check if result cached', () => {
66
+ const result = manager.isResultCached();
67
+ expect(typeof result).toBe('boolean');
68
+ });
69
+
70
+ it('should get cache time as number or null', () => {
71
+ const result = manager.getCacheTime();
72
+ expect(result === null || typeof result === 'number').toBe(true);
73
+ });
74
+
75
+ it('should get execution time as non-negative number', () => {
76
+ const result = manager.getExecutionTime();
77
+ expect(typeof result).toBe('number');
78
+ expect(result).toBeGreaterThanOrEqual(0);
79
+ });
80
+
81
+ it('should get result size as non-negative integer', () => {
82
+ const result = manager.getResultSize();
83
+ expect(typeof result).toBe('number');
84
+ expect(result).toBeGreaterThanOrEqual(0);
85
+ });
86
+
87
+ it('should check if result empty', () => {
88
+ const result = manager.isResultEmpty();
89
+ expect(typeof result).toBe('boolean');
90
+ });
91
+
92
+ it('should clear result and return boolean', () => {
93
+ const result = manager.clearResult();
94
+ expect(typeof result).toBe('boolean');
95
+ });
96
+
97
+ it('should clone result as object or null', () => {
98
+ const result = manager.cloneResult();
99
+ expect(result === null || typeof result === 'object').toBe(true);
100
+ });
101
+
102
+ it('should merge results and return boolean', () => {
103
+ const result = manager.mergeResults({});
104
+ expect(typeof result).toBe('boolean');
105
+ });
106
+
107
+ it('should validate result and return boolean', () => {
108
+ const result = manager.validateResult();
109
+ expect(typeof result).toBe('boolean');
110
+ });
111
+
112
+ it('should format result as string or null', () => {
113
+ const result = manager.formatResult('json');
114
+ expect(result === null || typeof result === 'string').toBe(true);
115
+ });
116
+
117
+ it('should export result and return boolean', () => {
118
+ const result = manager.exportResult('/output.json');
119
+ expect(typeof result).toBe('boolean');
120
+ });
121
+
122
+ it('should import result and return boolean', () => {
123
+ const result = manager.importResult('/input.json');
124
+ expect(typeof result).toBe('boolean');
125
+ });
126
+
127
+ it('should get result type as string or null', () => {
128
+ const result = manager.getResultType();
129
+ expect(result === null || typeof result === 'string').toBe(true);
130
+ });
131
+
132
+ it('should cast result to various types', () => {
133
+ const result = manager.castResult('int');
134
+ expect(result === null || typeof result === 'number' || typeof result === 'string' ||
135
+ typeof result === 'boolean').toBe(true);
136
+ });
137
+
138
+ it('should get result hash as string', () => {
139
+ const result = manager.getResultHash();
140
+ expect(typeof result).toBe('string');
141
+ });
142
+
143
+ it('should compare results and return boolean', () => {
144
+ const result = manager.compareResults({});
145
+ expect(typeof result).toBe('boolean');
146
+ });
147
+
148
+ it('should get result summary as string or null', () => {
149
+ const result = manager.getResultSummary();
150
+ expect(result === null || typeof result === 'string').toBe(true);
151
+ });
152
+
153
+ it('should convert result to format as string or null', () => {
154
+ const result = manager.convertResult('xml');
155
+ expect(result === null || typeof result === 'string').toBe(true);
156
+ });
157
+
158
+ it('should serialize result as string or null', () => {
159
+ const result = manager.serializeResult();
160
+ expect(result === null || typeof result === 'string').toBe(true);
161
+ });
162
+
163
+ it('should deserialize result and return boolean', () => {
164
+ const result = manager.deserializeResult('');
165
+ expect(typeof result).toBe('boolean');
166
+ });
167
+
168
+ it('should compress result and return boolean', () => {
169
+ const result = manager.compressResult();
170
+ expect(typeof result).toBe('boolean');
171
+ });
172
+
173
+ it('should decompress result and return boolean', () => {
174
+ const result = manager.decompressResult();
175
+ expect(typeof result).toBe('boolean');
176
+ });
177
+
178
+ it('should encrypt result and return boolean', () => {
179
+ const result = manager.encryptResult('password');
180
+ expect(typeof result).toBe('boolean');
181
+ });
182
+
183
+ it('should decrypt result and return boolean', () => {
184
+ const result = manager.decryptResult('password');
185
+ expect(typeof result).toBe('boolean');
186
+ });
187
+ });
188
+
189
+ describe('FormFieldManager', () => {
190
+ let manager: FormFieldManager;
191
+
192
+ beforeEach(() => {
193
+ manager = new FormFieldManager();
194
+ });
195
+
196
+ it('should get form fields as array', () => {
197
+ const result = manager.getFormFields();
198
+ expect(Array.isArray(result)).toBe(true);
199
+ });
200
+
201
+ it('should get field by name as object or null', () => {
202
+ const result = manager.getFieldByName('test_field');
203
+ expect(result === null || typeof result === 'object').toBe(true);
204
+ });
205
+
206
+ it('should get field value of various types', () => {
207
+ const result = manager.getFieldValue('field_1');
208
+ expect(result === null || typeof result === 'string' || typeof result === 'number' ||
209
+ typeof result === 'boolean').toBe(true);
210
+ });
211
+
212
+ it('should set field value and return boolean', () => {
213
+ const result = manager.setFieldValue('field_1', 'value');
214
+ expect(typeof result).toBe('boolean');
215
+ });
216
+
217
+ it('should get field type as string or null', () => {
218
+ const result = manager.getFieldType('field_1');
219
+ expect(result === null || typeof result === 'string').toBe(true);
220
+ });
221
+
222
+ it('should check if field required', () => {
223
+ const result = manager.isFieldRequired('field_1');
224
+ expect(typeof result).toBe('boolean');
225
+ });
226
+
227
+ it('should check if field readonly', () => {
228
+ const result = manager.isFieldReadOnly('field_1');
229
+ expect(typeof result).toBe('boolean');
230
+ });
231
+
232
+ it('should set field readonly and return boolean', () => {
233
+ const result = manager.setFieldReadOnly('field_1', true);
234
+ expect(typeof result).toBe('boolean');
235
+ });
236
+
237
+ it('should clear field value and return boolean', () => {
238
+ const result = manager.clearFieldValue('field_1');
239
+ expect(typeof result).toBe('boolean');
240
+ });
241
+
242
+ it('should validate field value and return boolean', () => {
243
+ const result = manager.validateFieldValue('field_1', 'value');
244
+ expect(typeof result).toBe('boolean');
245
+ });
246
+
247
+ it('should get field options as array or null', () => {
248
+ const result = manager.getFieldOptions('field_1');
249
+ expect(result === null || Array.isArray(result)).toBe(true);
250
+ });
251
+
252
+ it('should set field options and return boolean', () => {
253
+ const result = manager.setFieldOptions('field_1', ['opt1', 'opt2']);
254
+ expect(typeof result).toBe('boolean');
255
+ });
256
+
257
+ it('should flatten form and return boolean', () => {
258
+ const result = manager.flattenForm();
259
+ expect(typeof result).toBe('boolean');
260
+ });
261
+
262
+ it('should reset form and return boolean', () => {
263
+ const result = manager.resetForm();
264
+ expect(typeof result).toBe('boolean');
265
+ });
266
+
267
+ it('should export form data and return boolean', () => {
268
+ const result = manager.exportFormData('/output.fdf');
269
+ expect(typeof result).toBe('boolean');
270
+ });
271
+
272
+ it('should import form data and return boolean', () => {
273
+ const result = manager.importFormData('/input.fdf');
274
+ expect(typeof result).toBe('boolean');
275
+ });
276
+
277
+ it('should get form fields count as non-negative integer', () => {
278
+ const result = manager.getFormFieldsCount();
279
+ expect(typeof result).toBe('number');
280
+ expect(result).toBeGreaterThanOrEqual(0);
281
+ });
282
+
283
+ it('should calculate field positions and return boolean', () => {
284
+ const result = manager.calculateFieldPositions();
285
+ expect(typeof result).toBe('boolean');
286
+ });
287
+
288
+ it('should auto size fields and return boolean', () => {
289
+ const result = manager.autoSizeFields();
290
+ expect(typeof result).toBe('boolean');
291
+ });
292
+
293
+ it('should set field format and return boolean', () => {
294
+ const result = manager.setFieldFormat('field_1', 'text');
295
+ expect(typeof result).toBe('boolean');
296
+ });
297
+
298
+ it('should validate all fields and return boolean', () => {
299
+ const result = manager.validateAllFields();
300
+ expect(typeof result).toBe('boolean');
301
+ });
302
+
303
+ it('should complete form field lifecycle', () => {
304
+ const fields = manager.getFormFields();
305
+ expect(Array.isArray(fields)).toBe(true);
306
+
307
+ manager.setFieldValue('field_1', 'test_value');
308
+ const value = manager.getFieldValue('field_1');
309
+ expect(value !== undefined).toBe(true);
310
+
311
+ manager.validateAllFields();
312
+ manager.resetForm();
313
+ });
314
+ });
315
+ });
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Comprehensive test suite for Phase 2 High-Demand Features.
3
+ * Tests: BarcodesManager, SignaturesManager, RenderingManager
4
+ */
5
+
6
+ import { describe, it, expect, beforeEach } from '@jest/globals';
7
+
8
+ import BarcodesManager from '../managers/barcodes-manager';
9
+ import SignaturesManager from '../managers/signatures-manager';
10
+ import RenderingManager from '../managers/rendering-manager';
11
+
12
+ describe('Phase 2 High-Demand Features', () => {
13
+ describe('BarcodesManager', () => {
14
+ let manager: BarcodesManager;
15
+
16
+ beforeEach(() => {
17
+ manager = new BarcodesManager();
18
+ });
19
+
20
+ it('should generate QR code and return boolean', () => {
21
+ const result = manager.generateQRCode('test_data');
22
+ expect(typeof result).toBe('boolean');
23
+ });
24
+
25
+ it('should generate 1D barcode and return boolean', () => {
26
+ const result = manager.generateBarcode1D('CODE128', '123456');
27
+ expect(typeof result).toBe('boolean');
28
+ });
29
+
30
+ it('should generate 2D barcode and return boolean', () => {
31
+ const result = manager.generateBarcode2D('DATAMATRIX', 'test_data');
32
+ expect(typeof result).toBe('boolean');
33
+ });
34
+
35
+ it('should export barcode and return boolean', () => {
36
+ const result = manager.exportBarcode('/output.png');
37
+ expect(typeof result).toBe('boolean');
38
+ });
39
+
40
+ it('should export barcode as SVG and return boolean', () => {
41
+ const result = manager.exportBarcodeSVG('/output.svg');
42
+ expect(typeof result).toBe('boolean');
43
+ });
44
+
45
+ it('should get barcode data as string or null', () => {
46
+ const result = manager.getBarcodeData();
47
+ expect(result === null || typeof result === 'string').toBe(true);
48
+ });
49
+
50
+ it('should validate barcode and return boolean', () => {
51
+ const result = manager.validateBarcode('123456');
52
+ expect(typeof result).toBe('boolean');
53
+ });
54
+
55
+ it('should get barcode size as object or null', () => {
56
+ const result = manager.getBarcodeSize();
57
+ expect(result === null || typeof result === 'object').toBe(true);
58
+ });
59
+
60
+ it('should set barcode properties and return boolean', () => {
61
+ const result = manager.setBarcodeProperties({ width: 100 });
62
+ expect(typeof result).toBe('boolean');
63
+ });
64
+ });
65
+
66
+ describe('SignaturesManager', () => {
67
+ let manager: SignaturesManager;
68
+
69
+ beforeEach(() => {
70
+ manager = new SignaturesManager();
71
+ });
72
+
73
+ it('should sign document and return boolean', () => {
74
+ const result = manager.signDocument('/cert.pfx', 'password');
75
+ expect(typeof result).toBe('boolean');
76
+ });
77
+
78
+ it('should verify signature and return boolean', () => {
79
+ const result = manager.verifySignature();
80
+ expect(typeof result).toBe('boolean');
81
+ });
82
+
83
+ it('should get signature info as object or null', () => {
84
+ const result = manager.getSignatureInfo();
85
+ expect(result === null || typeof result === 'object').toBe(true);
86
+ });
87
+
88
+ it('should get certificate as object or null', () => {
89
+ const result = manager.getCertificate();
90
+ expect(result === null || typeof result === 'object').toBe(true);
91
+ });
92
+
93
+ it('should get certificate chain as array or null', () => {
94
+ const result = manager.getCertificateChain();
95
+ expect(result === null || Array.isArray(result)).toBe(true);
96
+ });
97
+
98
+ it('should validate certificate and return boolean', () => {
99
+ const result = manager.validateCertificate();
100
+ expect(typeof result).toBe('boolean');
101
+ });
102
+
103
+ it('should get signature count as non-negative number', () => {
104
+ const result = manager.getSignatureCount();
105
+ expect(typeof result).toBe('number');
106
+ expect(result).toBeGreaterThanOrEqual(0);
107
+ });
108
+
109
+ it('should get signature timestamp as number or null', () => {
110
+ const result = manager.getSignatureTimestamp();
111
+ expect(result === null || typeof result === 'number').toBe(true);
112
+ });
113
+
114
+ it('should remove signature and return boolean', () => {
115
+ const result = manager.removeSignature(0);
116
+ expect(typeof result).toBe('boolean');
117
+ });
118
+
119
+ it('should clear all signatures and return boolean', () => {
120
+ const result = manager.clearAllSignatures();
121
+ expect(typeof result).toBe('boolean');
122
+ });
123
+
124
+ it('should export signature and return boolean', () => {
125
+ const result = manager.exportSignature(0, '/output.p7s');
126
+ expect(typeof result).toBe('boolean');
127
+ });
128
+
129
+ it('should import signature and return boolean', () => {
130
+ const result = manager.importSignature('/input.p7s');
131
+ expect(typeof result).toBe('boolean');
132
+ });
133
+
134
+ it('should get signature algorithm as string or null', () => {
135
+ const result = manager.getSignatureAlgorithm();
136
+ expect(result === null || typeof result === 'string').toBe(true);
137
+ });
138
+
139
+ it('should set signature properties and return boolean', () => {
140
+ const result = manager.setSignatureProperties({ reason: 'Approval' });
141
+ expect(typeof result).toBe('boolean');
142
+ });
143
+
144
+ it('should add timestamp and return boolean', () => {
145
+ const result = manager.addTimestamp('http://timestamp.server.com');
146
+ expect(typeof result).toBe('boolean');
147
+ });
148
+
149
+ it('should verify timestamp and return boolean', () => {
150
+ const result = manager.verifyTimestamp();
151
+ expect(typeof result).toBe('boolean');
152
+ });
153
+ });
154
+
155
+ describe('RenderingManager', () => {
156
+ let manager: RenderingManager;
157
+
158
+ beforeEach(() => {
159
+ manager = new RenderingManager();
160
+ });
161
+
162
+ it('should render page and return boolean', () => {
163
+ const result = manager.renderPage(0, 150);
164
+ expect(typeof result).toBe('boolean');
165
+ });
166
+
167
+ it('should render page to file and return boolean', () => {
168
+ const result = manager.renderPageToFile(0, '/output.png', 150);
169
+ expect(typeof result).toBe('boolean');
170
+ });
171
+
172
+ it('should render region and return boolean', () => {
173
+ const result = manager.renderRegion(0, 0, 0, 100, 100);
174
+ expect(typeof result).toBe('boolean');
175
+ });
176
+
177
+ it('should render thumbnail and return boolean', () => {
178
+ const result = manager.renderThumbnail(0, 150);
179
+ expect(typeof result).toBe('boolean');
180
+ });
181
+
182
+ it('should set render quality and return boolean', () => {
183
+ const result = manager.setRenderQuality('high');
184
+ expect(typeof result).toBe('boolean');
185
+ });
186
+
187
+ it('should get rendered image as object or null', () => {
188
+ const result = manager.getRenderedImage();
189
+ expect(result === null || typeof result === 'object').toBe(true);
190
+ });
191
+
192
+ it('should render fit page and return boolean', () => {
193
+ const result = manager.renderFitPage(0);
194
+ expect(typeof result).toBe('boolean');
195
+ });
196
+
197
+ it('should render fit width and return boolean', () => {
198
+ const result = manager.renderFitWidth(0);
199
+ expect(typeof result).toBe('boolean');
200
+ });
201
+
202
+ it('should render fit height and return boolean', () => {
203
+ const result = manager.renderFitHeight(0);
204
+ expect(typeof result).toBe('boolean');
205
+ });
206
+
207
+ it('should render with zoom and return boolean', () => {
208
+ const result = manager.renderWithZoom(0, 1.5);
209
+ expect(typeof result).toBe('boolean');
210
+ });
211
+
212
+ it('should render rotated and return boolean', () => {
213
+ const result = manager.renderRotated(0, 90);
214
+ expect(typeof result).toBe('boolean');
215
+ });
216
+
217
+ it('should export as image and return boolean', () => {
218
+ const result = manager.exportAsImage(0, '/output.png', 'png');
219
+ expect(typeof result).toBe('boolean');
220
+ });
221
+
222
+ it('should export as JPEG and return boolean', () => {
223
+ const result = manager.exportAsJPEG(0, '/output.jpg', 85);
224
+ expect(typeof result).toBe('boolean');
225
+ });
226
+
227
+ it('should export as PNG and return boolean', () => {
228
+ const result = manager.exportAsPNG(0, '/output.png');
229
+ expect(typeof result).toBe('boolean');
230
+ });
231
+
232
+ it('should get render metrics as object or null', () => {
233
+ const result = manager.getRenderMetrics();
234
+ expect(result === null || typeof result === 'object').toBe(true);
235
+ });
236
+
237
+ it('should render all pages and return boolean', () => {
238
+ const result = manager.renderAllPages('/output_dir', 150);
239
+ expect(typeof result).toBe('boolean');
240
+ });
241
+
242
+ it('should cancel rendering and return boolean', () => {
243
+ const result = manager.cancelRendering();
244
+ expect(typeof result).toBe('boolean');
245
+ });
246
+
247
+ it('should set render timeout and return boolean', () => {
248
+ const result = manager.setRenderTimeout(30);
249
+ expect(typeof result).toBe('boolean');
250
+ });
251
+
252
+ it('should render with options and return boolean', () => {
253
+ const result = manager.renderWithOptions(0, { quality: 'high' });
254
+ expect(typeof result).toBe('boolean');
255
+ });
256
+ });
257
+ });
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Comprehensive test suite for Phase 4 Specialized Features.
3
+ * Tests: DOMElementsManager, PDFCreatorManager
4
+ */
5
+
6
+ import { describe, it, expect, beforeEach } from '@jest/globals';
7
+
8
+ import DOMElementsManager from '../managers/dom-elements-manager';
9
+ import PDFCreatorManager from '../managers/pdf-creator-manager';
10
+
11
+ describe('Phase 4 Specialized Features', () => {
12
+ describe('DOMElementsManager', () => {
13
+ let manager: DOMElementsManager;
14
+
15
+ beforeEach(() => {
16
+ manager = new DOMElementsManager();
17
+ });
18
+
19
+ it('should get element by ID as object or null', () => {
20
+ const result = manager.getElementByID('elem_1');
21
+ expect(result === null || typeof result === 'object').toBe(true);
22
+ });
23
+
24
+ it('should get elements by type as array or null', () => {
25
+ const result = manager.getElementByType('text');
26
+ expect(result === null || Array.isArray(result)).toBe(true);
27
+ });
28
+
29
+ it('should get element properties as object or null', () => {
30
+ const result = manager.getElementProperties('elem_1');
31
+ expect(result === null || typeof result === 'object').toBe(true);
32
+ });
33
+
34
+ it('should set element property and return boolean', () => {
35
+ const result = manager.setElementProperty('elem_1', 'color', '#FF0000');
36
+ expect(typeof result).toBe('boolean');
37
+ });
38
+
39
+ it('should remove element and return boolean', () => {
40
+ const result = manager.removeElement('elem_1');
41
+ expect(typeof result).toBe('boolean');
42
+ });
43
+
44
+ it('should get element children as array or null', () => {
45
+ const result = manager.getElementChildren('elem_1');
46
+ expect(result === null || Array.isArray(result)).toBe(true);
47
+ });
48
+
49
+ it('should get element parent as object or null', () => {
50
+ const result = manager.getElementParent('elem_1');
51
+ expect(result === null || typeof result === 'object').toBe(true);
52
+ });
53
+ });
54
+
55
+ describe('PDFCreatorManager', () => {
56
+ let manager: PDFCreatorManager;
57
+
58
+ beforeEach(() => {
59
+ manager = new PDFCreatorManager();
60
+ });
61
+
62
+ it('should create blank document and return boolean', () => {
63
+ const result = manager.createBlankDocument(612, 792);
64
+ expect(typeof result).toBe('boolean');
65
+ });
66
+
67
+ it('should create from images and return boolean', () => {
68
+ const result = manager.createFromImages(['/img1.png', '/img2.png']);
69
+ expect(typeof result).toBe('boolean');
70
+ });
71
+
72
+ it('should add page from template and return boolean', () => {
73
+ const result = manager.addPageFromTemplate('template_1');
74
+ expect(typeof result).toBe('boolean');
75
+ });
76
+
77
+ it('should create booklet and return boolean', () => {
78
+ const result = manager.createBooklet();
79
+ expect(typeof result).toBe('boolean');
80
+ });
81
+
82
+ it('should create multiple columns and return boolean', () => {
83
+ const result = manager.createMultipleColumns(2);
84
+ expect(typeof result).toBe('boolean');
85
+ });
86
+
87
+ it('should add custom page size and return boolean', () => {
88
+ const result = manager.addCustomPageSize(400, 600);
89
+ expect(typeof result).toBe('boolean');
90
+ });
91
+
92
+ it('should save as template and return boolean', () => {
93
+ const result = manager.saveAsTemplate('template_2');
94
+ expect(typeof result).toBe('boolean');
95
+ });
96
+ });
97
+ });