|
| 1 | +import {assertTypeOf} from 'run-time-assertions'; |
1 | 2 | import {assert} from 'chai';
|
2 | 3 | import {existsSync} from 'fs';
|
3 | 4 | import {join} from 'path';
|
4 |
| -import {ReadonlyDeep} from 'type-fest'; |
5 |
| -import {PdfProgressData, readPdfPages, readPdfText} from './read-pdf'; |
| 5 | +import type {ReadonlyDeep} from 'type-fest'; |
| 6 | +import {PdfProgressData, ReadPdfTextParams, readPdfPages, readPdfText} from './read-pdf'; |
6 | 7 | import {nodeModulesDir, sampleFilesDir} from './repo-paths.test-helper';
|
| 8 | +import type {TypedArray} from 'pdfjs-dist/types/src/display/api'; |
7 | 9 |
|
8 | 10 | type PdfTestFile = {
|
9 | 11 | filePath: string;
|
@@ -112,6 +114,9 @@ describe(readPdfPages.name, () => {
|
112 | 114 | progressCallback(progressData) {
|
113 | 115 | allProgressData.push(progressData);
|
114 | 116 | },
|
| 117 | + options: { |
| 118 | + isEvalSupported: false, |
| 119 | + }, |
115 | 120 | });
|
116 | 121 |
|
117 | 122 | assert.isAbove(allProgressData.length, 0, 'got no progress data');
|
@@ -142,3 +147,13 @@ describe(readPdfText.name, () => {
|
142 | 147 | });
|
143 | 148 | });
|
144 | 149 | });
|
| 150 | + |
| 151 | +describe('ReadPdfTextParams', () => { |
| 152 | + it('matches expected types', () => { |
| 153 | + assertTypeOf<Required<ReadPdfTextParams>['data']>().toEqualTypeOf< |
| 154 | + string | number[] | ArrayBuffer | TypedArray |
| 155 | + >(); |
| 156 | + assertTypeOf<Required<ReadPdfTextParams>['url']>().toEqualTypeOf<string | URL>(); |
| 157 | + assertTypeOf<Required<ReadPdfTextParams>['filePath']>().toEqualTypeOf<string | URL>(); |
| 158 | + }); |
| 159 | +}); |
0 commit comments