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.
Files changed (3) hide show
  1. package/index.js +1 -0
  2. package/package.json +1 -1
  3. package/test/test.js +7 -12
package/index.js CHANGED
@@ -73,6 +73,7 @@ async function ocrSpace(input, options = {}) {
73
73
  return data;
74
74
  } catch (error) {
75
75
  console.error(error);
76
+ throw error;
76
77
  }
77
78
  }
78
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocr-space-api-wrapper",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
4
4
  "description": "Node.js wrapper for ocr.space APIs.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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 return undefined if input is wrong', async () => {
6
- const res1 = await ocrSpace();
7
- assert.strictEqual(res1, undefined);
8
- const res2 = await ocrSpace('');
9
- assert.strictEqual(res2, undefined);
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 abort the request', async () => {
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
- const res1 = await promise;
85
- assert.strictEqual(res1, undefined);
80
+ await assert.rejects(promise);
86
81
  });
87
82
  });