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.
- package/README.md +218 -0
- package/binding.gyp +35 -0
- package/package.json +78 -0
- package/src/builders/annotation-builder.ts +367 -0
- package/src/builders/conversion-options-builder.ts +257 -0
- package/src/builders/index.ts +12 -0
- package/src/builders/metadata-builder.ts +317 -0
- package/src/builders/pdf-builder.ts +386 -0
- package/src/builders/search-options-builder.ts +151 -0
- package/src/document-editor-manager.ts +318 -0
- package/src/errors.ts +1629 -0
- package/src/form-field-manager.ts +666 -0
- package/src/hybrid-ml-manager.ts +283 -0
- package/src/index.ts +453 -0
- package/src/managers/accessibility-manager.ts +338 -0
- package/src/managers/annotation-manager.ts +439 -0
- package/src/managers/barcode-manager.ts +235 -0
- package/src/managers/batch-manager.ts +533 -0
- package/src/managers/cache-manager.ts +486 -0
- package/src/managers/compliance-manager.ts +375 -0
- package/src/managers/content-manager.ts +339 -0
- package/src/managers/document-utility-manager.ts +922 -0
- package/src/managers/dom-pdf-creator.ts +365 -0
- package/src/managers/editing-manager.ts +514 -0
- package/src/managers/enterprise-manager.ts +478 -0
- package/src/managers/extended-managers.ts +437 -0
- package/src/managers/extraction-manager.ts +583 -0
- package/src/managers/final-utilities.ts +429 -0
- package/src/managers/hybrid-ml-advanced.ts +479 -0
- package/src/managers/index.ts +239 -0
- package/src/managers/layer-manager.ts +500 -0
- package/src/managers/metadata-manager.ts +303 -0
- package/src/managers/ocr-manager.ts +756 -0
- package/src/managers/optimization-manager.ts +262 -0
- package/src/managers/outline-manager.ts +196 -0
- package/src/managers/page-manager.ts +289 -0
- package/src/managers/pattern-detection.ts +440 -0
- package/src/managers/rendering-manager.ts +863 -0
- package/src/managers/search-manager.ts +385 -0
- package/src/managers/security-manager.ts +345 -0
- package/src/managers/signature-manager.ts +1664 -0
- package/src/managers/streams.ts +618 -0
- package/src/managers/xfa-manager.ts +500 -0
- package/src/pdf-creator-manager.ts +494 -0
- package/src/properties.ts +522 -0
- package/src/result-accessors-manager.ts +867 -0
- package/src/tests/advanced-features.test.ts +414 -0
- package/src/tests/advanced.test.ts +266 -0
- package/src/tests/extended-managers.test.ts +316 -0
- package/src/tests/final-utilities.test.ts +455 -0
- package/src/tests/foundation.test.ts +315 -0
- package/src/tests/high-demand.test.ts +257 -0
- package/src/tests/specialized.test.ts +97 -0
- package/src/thumbnail-manager.ts +272 -0
- package/src/types/common.ts +142 -0
- package/src/types/document-types.ts +457 -0
- package/src/types/index.ts +6 -0
- package/src/types/manager-types.ts +284 -0
- package/src/types/native-bindings.ts +517 -0
- package/src/workers/index.ts +7 -0
- package/src/workers/pool.ts +274 -0
- package/src/workers/worker.ts +131 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive test suite for Phase 5 Advanced Features.
|
|
3
|
+
* Tests: AnnotationsAdvancedManager, LayoutAnalysisManager, DOMAdvancedManager, XFAManager, SearchAdvancedManager
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
7
|
+
|
|
8
|
+
import AnnotationsAdvancedManager from '../managers/annotations-advanced-manager';
|
|
9
|
+
import LayoutAnalysisManager from '../managers/layout-analysis-manager';
|
|
10
|
+
import DOMAdvancedManager from '../managers/dom-advanced-manager';
|
|
11
|
+
import XFAManager from '../managers/xfa-manager';
|
|
12
|
+
import SearchAdvancedManager from '../managers/search-advanced-manager';
|
|
13
|
+
|
|
14
|
+
describe('Phase 5 Advanced Features', () => {
|
|
15
|
+
describe('AnnotationsAdvancedManager', () => {
|
|
16
|
+
let manager: AnnotationsAdvancedManager;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
manager = new AnnotationsAdvancedManager();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should add ink annotation', () => {
|
|
23
|
+
const result = manager.addInkAnnotation(0, [[10, 20], [30, 40]]);
|
|
24
|
+
expect(typeof result).toBe('boolean');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should add polygon annotation', () => {
|
|
28
|
+
const result = manager.addPolygonAnnotation(0, [[10, 20], [30, 40], [50, 60]]);
|
|
29
|
+
expect(typeof result).toBe('boolean');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should add polyline annotation', () => {
|
|
33
|
+
const result = manager.addPolylineAnnotation(0, [[10, 20], [30, 40]]);
|
|
34
|
+
expect(typeof result).toBe('boolean');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should add file attachment', () => {
|
|
38
|
+
const result = manager.addFileAttachment(0, '/file.txt', 'Description');
|
|
39
|
+
expect(typeof result).toBe('boolean');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should add sound annotation', () => {
|
|
43
|
+
const result = manager.addSoundAnnotation(0, '/sound.mp3');
|
|
44
|
+
expect(typeof result).toBe('boolean');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should add movie annotation', () => {
|
|
48
|
+
const result = manager.addMovieAnnotation(0, '/movie.mp4');
|
|
49
|
+
expect(typeof result).toBe('boolean');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should get annotation appearance', () => {
|
|
53
|
+
const result = manager.getAnnotationAppearance('anno_1');
|
|
54
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should set annotation appearance', () => {
|
|
58
|
+
const result = manager.setAnnotationAppearance('anno_1', { color: 'red' });
|
|
59
|
+
expect(typeof result).toBe('boolean');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should get annotation popup', () => {
|
|
63
|
+
const result = manager.getAnnotationPopup('anno_1');
|
|
64
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should set annotation popup', () => {
|
|
68
|
+
const result = manager.setAnnotationPopup('anno_1', 'Popup text');
|
|
69
|
+
expect(typeof result).toBe('boolean');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should get annotation flags', () => {
|
|
73
|
+
const result = manager.getAnnotationFlags('anno_1');
|
|
74
|
+
expect(typeof result).toBe('number');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should set annotation flags', () => {
|
|
78
|
+
const result = manager.setAnnotationFlags('anno_1', 4);
|
|
79
|
+
expect(typeof result).toBe('boolean');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should group annotations', () => {
|
|
83
|
+
const result = manager.groupAnnotations(['anno_1', 'anno_2']);
|
|
84
|
+
expect(typeof result).toBe('boolean');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should ungroup annotations', () => {
|
|
88
|
+
const result = manager.ungroupAnnotations('group_1');
|
|
89
|
+
expect(typeof result).toBe('boolean');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should get annotation rotation point', () => {
|
|
93
|
+
const result = manager.getAnnotationRotationPoint('anno_1');
|
|
94
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should set annotation rotation', () => {
|
|
98
|
+
const result = manager.setAnnotationRotation('anno_1', 45);
|
|
99
|
+
expect(typeof result).toBe('boolean');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should get annotation transparency', () => {
|
|
103
|
+
const result = manager.getAnnotationTransparency('anno_1');
|
|
104
|
+
expect(typeof result).toBe('number');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should set annotation transparency', () => {
|
|
108
|
+
const result = manager.setAnnotationTransparency('anno_1', 0.5);
|
|
109
|
+
expect(typeof result).toBe('boolean');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should animate annotation', () => {
|
|
113
|
+
const result = manager.animateAnnotation('anno_1');
|
|
114
|
+
expect(typeof result).toBe('boolean');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should get 3D annotation', () => {
|
|
118
|
+
const result = manager.getAnnotation3D('anno_1');
|
|
119
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should get all annotation metadata', () => {
|
|
123
|
+
const result = manager.getAllAnnotationMetadata();
|
|
124
|
+
expect(typeof result).toBe('object');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should export annotations to XFDF', () => {
|
|
128
|
+
const result = manager.exportAnnotationsXFDF('/output.xfdf');
|
|
129
|
+
expect(typeof result).toBe('boolean');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('LayoutAnalysisManager', () => {
|
|
134
|
+
let manager: LayoutAnalysisManager;
|
|
135
|
+
|
|
136
|
+
beforeEach(() => {
|
|
137
|
+
manager = new LayoutAnalysisManager();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should detect columns', () => {
|
|
141
|
+
const result = manager.detectColumns();
|
|
142
|
+
expect(Array.isArray(result)).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should detect tables', () => {
|
|
146
|
+
const result = manager.detectTables();
|
|
147
|
+
expect(Array.isArray(result)).toBe(true);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should get table structure', () => {
|
|
151
|
+
const result = manager.getTableStructure(0);
|
|
152
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should extract table data', () => {
|
|
156
|
+
const result = manager.extractTableData(0);
|
|
157
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should detect headers', () => {
|
|
161
|
+
const result = manager.detectHeaders();
|
|
162
|
+
expect(Array.isArray(result)).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should detect footers', () => {
|
|
166
|
+
const result = manager.detectFooters();
|
|
167
|
+
expect(Array.isArray(result)).toBe(true);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should detect page margins', () => {
|
|
171
|
+
const result = manager.detectPageMargins();
|
|
172
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should get text flow', () => {
|
|
176
|
+
const result = manager.getTextFlow();
|
|
177
|
+
expect(Array.isArray(result)).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should analyze page layout', () => {
|
|
181
|
+
const result = manager.analyzePageLayout();
|
|
182
|
+
expect(typeof result).toBe('object');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('should detect reading order', () => {
|
|
186
|
+
const result = manager.detectReadingOrder();
|
|
187
|
+
expect(Array.isArray(result)).toBe(true);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('should get layout regions', () => {
|
|
191
|
+
const result = manager.getLayoutRegions();
|
|
192
|
+
expect(Array.isArray(result)).toBe(true);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should export layout analysis', () => {
|
|
196
|
+
const result = manager.exportLayoutAnalysis('/output.json');
|
|
197
|
+
expect(typeof result).toBe('boolean');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('should detect images', () => {
|
|
201
|
+
const result = manager.detectImages();
|
|
202
|
+
expect(Array.isArray(result)).toBe(true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('should detect graphics', () => {
|
|
206
|
+
const result = manager.detectGraphics();
|
|
207
|
+
expect(Array.isArray(result)).toBe(true);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should detect form fields', () => {
|
|
211
|
+
const result = manager.detectFormFields();
|
|
212
|
+
expect(Array.isArray(result)).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should get layout statistics', () => {
|
|
216
|
+
const result = manager.getLayoutStatistics();
|
|
217
|
+
expect(typeof result).toBe('object');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should validate layout', () => {
|
|
221
|
+
const result = manager.validateLayout();
|
|
222
|
+
expect(typeof result).toBe('boolean');
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('DOMAdvancedManager', () => {
|
|
227
|
+
let manager: DOMAdvancedManager;
|
|
228
|
+
|
|
229
|
+
beforeEach(() => {
|
|
230
|
+
manager = new DOMAdvancedManager();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should create DOM tree', () => {
|
|
234
|
+
const result = manager.createDOMTree();
|
|
235
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should traverse DOM', () => {
|
|
239
|
+
const result = manager.traverseDOM();
|
|
240
|
+
expect(Array.isArray(result)).toBe(true);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should find DOM element', () => {
|
|
244
|
+
const result = manager.findDOMElement('tag', 'text');
|
|
245
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should modify DOM element', () => {
|
|
249
|
+
const result = manager.modifyDOMElement('elem_1', { text: 'new' });
|
|
250
|
+
expect(typeof result).toBe('boolean');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should insert DOM element', () => {
|
|
254
|
+
const result = manager.insertDOMElement('parent_1', { text: 'new' });
|
|
255
|
+
expect(typeof result).toBe('boolean');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('should delete DOM element', () => {
|
|
259
|
+
const result = manager.deleteDOMElement('elem_1');
|
|
260
|
+
expect(typeof result).toBe('boolean');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('should clone DOM element', () => {
|
|
264
|
+
const result = manager.cloneDOMElement('elem_1');
|
|
265
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should get DOM attributes', () => {
|
|
269
|
+
const result = manager.getDOMAttributes('elem_1');
|
|
270
|
+
expect(typeof result).toBe('object');
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('should set DOM attributes', () => {
|
|
274
|
+
const result = manager.setDOMAttributes('elem_1', { attr: 'value' });
|
|
275
|
+
expect(typeof result).toBe('boolean');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should get DOM text', () => {
|
|
279
|
+
const result = manager.getDOMText('elem_1');
|
|
280
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('should set DOM text', () => {
|
|
284
|
+
const result = manager.setDOMText('elem_1', 'new text');
|
|
285
|
+
expect(typeof result).toBe('boolean');
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('should export DOM', () => {
|
|
289
|
+
const result = manager.exportDOM('/output.xml');
|
|
290
|
+
expect(typeof result).toBe('boolean');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('should import DOM', () => {
|
|
294
|
+
const result = manager.importDOM('/input.xml');
|
|
295
|
+
expect(typeof result).toBe('boolean');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should validate DOM structure', () => {
|
|
299
|
+
const result = manager.validateDOMStructure();
|
|
300
|
+
expect(typeof result).toBe('boolean');
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('should get DOM statistics', () => {
|
|
304
|
+
const result = manager.getDOMStatistics();
|
|
305
|
+
expect(typeof result).toBe('object');
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
describe('XFAManager', () => {
|
|
310
|
+
let manager: XFAManager;
|
|
311
|
+
|
|
312
|
+
beforeEach(() => {
|
|
313
|
+
manager = new XFAManager();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should get XFA form', () => {
|
|
317
|
+
const result = manager.getXFAForm();
|
|
318
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('should check if XFA form', () => {
|
|
322
|
+
const result = manager.isXFAForm();
|
|
323
|
+
expect(typeof result).toBe('boolean');
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should extract XFA data', () => {
|
|
327
|
+
const result = manager.extractXFAData();
|
|
328
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('should set XFA data', () => {
|
|
332
|
+
const result = manager.setXFAData({ field: 'value' });
|
|
333
|
+
expect(typeof result).toBe('boolean');
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('should export XFA template', () => {
|
|
337
|
+
const result = manager.exportXFATemplate('/output.xml');
|
|
338
|
+
expect(typeof result).toBe('boolean');
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('should import XFA template', () => {
|
|
342
|
+
const result = manager.importXFATemplate('/input.xml');
|
|
343
|
+
expect(typeof result).toBe('boolean');
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('should validate XFA form', () => {
|
|
347
|
+
const result = manager.validateXFAForm();
|
|
348
|
+
expect(typeof result).toBe('boolean');
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('should convert XFA to AcroForm', () => {
|
|
352
|
+
const result = manager.convertXFAToAcroForm();
|
|
353
|
+
expect(typeof result).toBe('boolean');
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('should get XFA field value', () => {
|
|
357
|
+
const result = manager.getXFAFieldValue('field');
|
|
358
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('should set XFA field value', () => {
|
|
362
|
+
const result = manager.setXFAFieldValue('field', 'value');
|
|
363
|
+
expect(typeof result).toBe('boolean');
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('should get XFA field properties', () => {
|
|
367
|
+
const result = manager.getXFAFieldProperties('field');
|
|
368
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('should reset XFA form', () => {
|
|
372
|
+
const result = manager.resetXFAForm();
|
|
373
|
+
expect(typeof result).toBe('boolean');
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('should get XFA calculations', () => {
|
|
377
|
+
const result = manager.getXFACalculations();
|
|
378
|
+
expect(typeof result).toBe('object');
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
describe('SearchAdvancedManager', () => {
|
|
383
|
+
let manager: SearchAdvancedManager;
|
|
384
|
+
|
|
385
|
+
beforeEach(() => {
|
|
386
|
+
manager = new SearchAdvancedManager();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('should search with regex', () => {
|
|
390
|
+
const result = manager.searchWithRegex(r'\d+');
|
|
391
|
+
expect(Array.isArray(result)).toBe(true);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should search with wildcards', () => {
|
|
395
|
+
const result = manager.searchWithWildcards('test*');
|
|
396
|
+
expect(Array.isArray(result)).toBe(true);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('should search within region', () => {
|
|
400
|
+
const result = manager.searchWithinRegion('text', 0, 0, 100, 100);
|
|
401
|
+
expect(Array.isArray(result)).toBe(true);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it('should search with options', () => {
|
|
405
|
+
const result = manager.searchWithOptions('text', { case_sensitive: true });
|
|
406
|
+
expect(Array.isArray(result)).toBe(true);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('should get search statistics', () => {
|
|
410
|
+
const result = manager.getSearchStatistics();
|
|
411
|
+
expect(typeof result).toBe('object');
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
});
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive test suite for Phase 3 Advanced Features.
|
|
3
|
+
* Tests: OCRManager, ComplianceManager, CacheManager
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
7
|
+
|
|
8
|
+
import OCRManager from '../managers/ocr-manager';
|
|
9
|
+
import ComplianceManager from '../managers/compliance-manager';
|
|
10
|
+
import CacheManager from '../managers/cache-manager';
|
|
11
|
+
|
|
12
|
+
describe('Phase 3 Advanced Features', () => {
|
|
13
|
+
describe('OCRManager', () => {
|
|
14
|
+
let manager: OCRManager;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
manager = new OCRManager();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should extract text with OCR as string or null', () => {
|
|
21
|
+
const result = manager.extractTextOCR();
|
|
22
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should recognize text as string or null', () => {
|
|
26
|
+
const result = manager.recognizeText();
|
|
27
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should detect language as string or null', () => {
|
|
31
|
+
const result = manager.detectLanguage();
|
|
32
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should get OCR confidence as number', () => {
|
|
36
|
+
const result = manager.getOCRConfidence();
|
|
37
|
+
expect(typeof result).toBe('number');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should set OCR language and return boolean', () => {
|
|
41
|
+
const result = manager.setOCRLanguage('eng');
|
|
42
|
+
expect(typeof result).toBe('boolean');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should get OCR languages as array or null', () => {
|
|
46
|
+
const result = manager.getOCRLanguages();
|
|
47
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should recognize characters as array or null', () => {
|
|
51
|
+
const result = manager.recognizeCharacters();
|
|
52
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should get character bounds as object or null', () => {
|
|
56
|
+
const result = manager.getCharacterBounds(0);
|
|
57
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should get confidence scores as array or null', () => {
|
|
61
|
+
const result = manager.getConfidenceScores();
|
|
62
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should detect text regions as array or null', () => {
|
|
66
|
+
const result = manager.detectTextRegions();
|
|
67
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should apply preprocessing and return boolean', () => {
|
|
71
|
+
const result = manager.applyPreprocessing('denoise');
|
|
72
|
+
expect(typeof result).toBe('boolean');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should set OCR mode and return boolean', () => {
|
|
76
|
+
const result = manager.setOCRMode('fast');
|
|
77
|
+
expect(typeof result).toBe('boolean');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should export OCR data and return boolean', () => {
|
|
81
|
+
const result = manager.exportOCRData('/output.json');
|
|
82
|
+
expect(typeof result).toBe('boolean');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should get OCR metrics as object or null', () => {
|
|
86
|
+
const result = manager.getOCRMetrics();
|
|
87
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should validate OCR result and return boolean', () => {
|
|
91
|
+
const result = manager.validateOCRResult();
|
|
92
|
+
expect(typeof result).toBe('boolean');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should set OCR timeout and return boolean', () => {
|
|
96
|
+
const result = manager.setOCRTimeout(60);
|
|
97
|
+
expect(typeof result).toBe('boolean');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should cancel OCR and return boolean', () => {
|
|
101
|
+
const result = manager.cancelOCR();
|
|
102
|
+
expect(typeof result).toBe('boolean');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should get OCR status as string or null', () => {
|
|
106
|
+
const result = manager.getOCRStatus();
|
|
107
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should perform batch OCR and return boolean', () => {
|
|
111
|
+
const result = manager.batchOCR([0, 1, 2]);
|
|
112
|
+
expect(typeof result).toBe('boolean');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('ComplianceManager', () => {
|
|
117
|
+
let manager: ComplianceManager;
|
|
118
|
+
|
|
119
|
+
beforeEach(() => {
|
|
120
|
+
manager = new ComplianceManager();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should validate PDF/X and return boolean', () => {
|
|
124
|
+
const result = manager.validatePDFX();
|
|
125
|
+
expect(typeof result).toBe('boolean');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should validate PDF/UA and return boolean', () => {
|
|
129
|
+
const result = manager.validatePDFUA();
|
|
130
|
+
expect(typeof result).toBe('boolean');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should validate PDF/A and return boolean', () => {
|
|
134
|
+
const result = manager.validatePDFA();
|
|
135
|
+
expect(typeof result).toBe('boolean');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should get compliance status as string or null', () => {
|
|
139
|
+
const result = manager.getComplianceStatus();
|
|
140
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should get compliance issues as array or null', () => {
|
|
144
|
+
const result = manager.getComplianceIssues();
|
|
145
|
+
expect(result === null || Array.isArray(result)).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should fix compliance issues and return boolean', () => {
|
|
149
|
+
const result = manager.fixComplianceIssues();
|
|
150
|
+
expect(typeof result).toBe('boolean');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should add accessibility tags and return boolean', () => {
|
|
154
|
+
const result = manager.addAccessibilityTags();
|
|
155
|
+
expect(typeof result).toBe('boolean');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should set language and return boolean', () => {
|
|
159
|
+
const result = manager.setLanguage('en');
|
|
160
|
+
expect(typeof result).toBe('boolean');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('should add document title and return boolean', () => {
|
|
164
|
+
const result = manager.addDocumentTitle('Document Title');
|
|
165
|
+
expect(typeof result).toBe('boolean');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should add metadata and return boolean', () => {
|
|
169
|
+
const result = manager.addMetadata({ key: 'value' });
|
|
170
|
+
expect(typeof result).toBe('boolean');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should remove compliance issues and return boolean', () => {
|
|
174
|
+
const result = manager.removeComplianceIssues();
|
|
175
|
+
expect(typeof result).toBe('boolean');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should get compliance report as string or null', () => {
|
|
179
|
+
const result = manager.getComplianceReport();
|
|
180
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should export compliance report and return boolean', () => {
|
|
184
|
+
const result = manager.exportComplianceReport('/report.txt');
|
|
185
|
+
expect(typeof result).toBe('boolean');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should set compliance mode and return boolean', () => {
|
|
189
|
+
const result = manager.setComplianceMode('PDFA');
|
|
190
|
+
expect(typeof result).toBe('boolean');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should validate images and return boolean', () => {
|
|
194
|
+
const result = manager.validateImages();
|
|
195
|
+
expect(typeof result).toBe('boolean');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should validate fonts and return boolean', () => {
|
|
199
|
+
const result = manager.validateFonts();
|
|
200
|
+
expect(typeof result).toBe('boolean');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should validate colors and return boolean', () => {
|
|
204
|
+
const result = manager.validateColors();
|
|
205
|
+
expect(typeof result).toBe('boolean');
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should get compliance metrics as object or null', () => {
|
|
209
|
+
const result = manager.getComplianceMetrics();
|
|
210
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('should auto fix compliance and return boolean', () => {
|
|
214
|
+
const result = manager.autoFixCompliance();
|
|
215
|
+
expect(typeof result).toBe('boolean');
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('should reset compliance and return boolean', () => {
|
|
219
|
+
const result = manager.resetCompliance();
|
|
220
|
+
expect(typeof result).toBe('boolean');
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('should get compliance level as string or null', () => {
|
|
224
|
+
const result = manager.getComplianceLevel();
|
|
225
|
+
expect(result === null || typeof result === 'string').toBe(true);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('should validate content streams and return boolean', () => {
|
|
229
|
+
const result = manager.validateContentStreams();
|
|
230
|
+
expect(typeof result).toBe('boolean');
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe('CacheManager', () => {
|
|
235
|
+
let manager: CacheManager;
|
|
236
|
+
|
|
237
|
+
beforeEach(() => {
|
|
238
|
+
manager = new CacheManager();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should create cache and return boolean', () => {
|
|
242
|
+
const result = manager.createCache(1000);
|
|
243
|
+
expect(typeof result).toBe('boolean');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should get from cache as string, object or null', () => {
|
|
247
|
+
const result = manager.getFromCache('key');
|
|
248
|
+
expect(result === null || typeof result === 'string' || typeof result === 'object').toBe(true);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('should clear cache and return boolean', () => {
|
|
252
|
+
const result = manager.clearCache();
|
|
253
|
+
expect(typeof result).toBe('boolean');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('should get cache stats as object or null', () => {
|
|
257
|
+
const result = manager.getCacheStats();
|
|
258
|
+
expect(result === null || typeof result === 'object').toBe(true);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should set cache policy and return boolean', () => {
|
|
262
|
+
const result = manager.setCachePolicy('LRU');
|
|
263
|
+
expect(typeof result).toBe('boolean');
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
});
|