ocr-space-api-wrapper 2.4.5 → 2.4.6
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/index.js +1 -0
- package/package.json +1 -1
- package/test/test.js +7 -12
package/index.js
CHANGED
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -2,15 +2,11 @@ const assert = require('assert');
|
|
|
2
2
|
const { ocrSpace } = require('../index');
|
|
3
3
|
|
|
4
4
|
describe('Tests for OCR Space API Wrapper', () => {
|
|
5
|
-
it('should
|
|
6
|
-
|
|
7
|
-
assert.
|
|
8
|
-
|
|
9
|
-
assert.
|
|
10
|
-
const res3 = await ocrSpace(1);
|
|
11
|
-
assert.strictEqual(res3, undefined);
|
|
12
|
-
const res4 = await ocrSpace(true);
|
|
13
|
-
assert.strictEqual(res4, undefined);
|
|
5
|
+
it('should throw if input is wrong', async () => {
|
|
6
|
+
await assert.rejects(() => ocrSpace());
|
|
7
|
+
await assert.rejects(() => ocrSpace(''));
|
|
8
|
+
await assert.rejects(() => ocrSpace(1));
|
|
9
|
+
await assert.rejects(() => ocrSpace(true));
|
|
14
10
|
});
|
|
15
11
|
it('should return results with a URL input', async () => {
|
|
16
12
|
const res1 = await ocrSpace('http://dl.a9t9.com/ocrbenchmark/eng.png');
|
|
@@ -76,12 +72,11 @@ describe('Tests for OCR Space API Wrapper', () => {
|
|
|
76
72
|
assert.notStrictEqual(res1.SearchablePDFURL, 'Searchable PDF not generated as it was not requested.');
|
|
77
73
|
assert.match(res1.SearchablePDFURL, /https?:\/\/.*\.pdf/);
|
|
78
74
|
});
|
|
79
|
-
it('should
|
|
75
|
+
it('should throw if the request is aborted', async () => {
|
|
80
76
|
const controller = new AbortController();
|
|
81
77
|
const { signal } = controller;
|
|
82
78
|
const promise = ocrSpace('./test/eng.png', { signal });
|
|
83
79
|
controller.abort();
|
|
84
|
-
|
|
85
|
-
assert.strictEqual(res1, undefined);
|
|
80
|
+
await assert.rejects(promise);
|
|
86
81
|
});
|
|
87
82
|
});
|