Skip to content

Commit 6cf46c1

Browse files
committed
Ran linter on automated tests
1 parent 241cddb commit 6cf46c1

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

tests/FS.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const FS_WAIT = 500;
33
let worker;
44
before(async function cb() {
55
this.timeout(0);
6-
worker = await createWorker("eng", 1, OPTIONS);
6+
worker = await createWorker('eng', 1, OPTIONS);
77
});
88

99
describe('FS', async () => {

tests/detect.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { createWorker } = Tesseract;
22
let worker;
33
before(async function cb() {
44
this.timeout(0);
5-
worker = await createWorker("osd", 0, OPTIONS);
5+
worker = await createWorker('osd', 0, OPTIONS);
66
});
77

88
describe('detect()', async () => {
@@ -16,7 +16,6 @@ describe('detect()', async () => {
1616
}).timeout(TIMEOUT);
1717
});
1818

19-
2019
describe('detect()', async () => {
2120
it('should detect OSD (simplified interface)', () => {
2221
[

tests/recognize.test.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ const { createWorker, PSM } = Tesseract;
22
let worker;
33
before(async function cb() {
44
this.timeout(0);
5-
worker = await createWorker("eng", 1, OPTIONS);
6-
workerLegacy = await createWorker("eng", 0, OPTIONS);
5+
worker = await createWorker('eng', 1, OPTIONS);
6+
workerLegacy = await createWorker('eng', 0, OPTIONS);
77
});
88

99
describe('recognize()', () => {
1010
describe('should read bmp, jpg, png and pbm format images', () => {
11-
FORMATS.forEach(format => (
11+
FORMATS.forEach((format) => (
1212
it(`support ${format} format`, async () => {
1313
await worker.reinitialize('eng');
1414
const { data: { text } } = await worker.recognize(`${IMAGE_PATH}/simple.${format}`);
@@ -69,7 +69,6 @@ describe('recognize()', () => {
6969
));
7070
});
7171

72-
7372
describe('should recognize different langs', () => {
7473
[
7574
{ name: 'chinese.png', lang: 'chi_tra', ans: CHINESE_TEXT },
@@ -142,7 +141,7 @@ describe('recognize()', () => {
142141
describe('should support all page seg modes (Legacy)', () => {
143142
Object
144143
.keys(PSM)
145-
.map(name => ({ name, mode: PSM[name] }))
144+
.map((name) => ({ name, mode: PSM[name] }))
146145
.forEach(({ name, mode }) => (
147146
it(`support PSM.${name} mode`, async () => {
148147
await workerLegacy.reinitialize(['eng', 'osd']);
@@ -159,7 +158,7 @@ describe('recognize()', () => {
159158
Object
160159
.keys(PSM)
161160
.filter((x) => x !== 'OSD_ONLY')
162-
.map(name => ({ name, mode: PSM[name] }))
161+
.map((name) => ({ name, mode: PSM[name] }))
163162
.forEach(({ name, mode }) => (
164163
it(`support PSM.${name} mode`, async () => {
165164
await worker.reinitialize(['eng', 'osd']);
@@ -173,7 +172,7 @@ describe('recognize()', () => {
173172
});
174173

175174
(IS_BROWSER ? describe.skip : describe)('should recognize image in Buffer format (Node.js only)', () => {
176-
FORMATS.forEach(format => (
175+
FORMATS.forEach((format) => (
177176
it(`support ${format} format`, async () => {
178177
const buf = fs.readFileSync(path.join(__dirname, 'assets', 'images', `simple.${format}`));
179178
await worker.reinitialize('eng');
@@ -184,7 +183,7 @@ describe('recognize()', () => {
184183
});
185184

186185
(IS_BROWSER ? describe : describe.skip)('should read image from img DOM element (browser only)', () => {
187-
FORMATS.forEach(format => (
186+
FORMATS.forEach((format) => (
188187
it(`support ${format} format`, async () => {
189188
const imageDOM = document.createElement('img');
190189
imageDOM.setAttribute('src', `${IMAGE_PATH}/simple.${format}`);
@@ -196,7 +195,7 @@ describe('recognize()', () => {
196195
});
197196

198197
(IS_BROWSER ? describe : describe.skip)('should read image from video DOM element (browser only)', () => {
199-
FORMATS.forEach(format => (
198+
FORMATS.forEach((format) => (
200199
it(`support ${format} format`, async () => {
201200
const videoDOM = document.createElement('video');
202201
videoDOM.setAttribute('poster', `${IMAGE_PATH}/simple.${format}`);
@@ -209,7 +208,7 @@ describe('recognize()', () => {
209208

210209
(IS_BROWSER ? describe : describe.skip)('should read video from canvas DOM element (browser only)', () => {
211210
// img tag is unable to render pbm, so let's skip it.
212-
const formats = FORMATS.filter(f => f !== 'pbm');
211+
const formats = FORMATS.filter((f) => f !== 'pbm');
213212
let canvasDOM = null;
214213
let imageDOM = null;
215214
let idx = 0;
@@ -230,7 +229,7 @@ describe('recognize()', () => {
230229
imageDOM.remove();
231230
});
232231

233-
formats.forEach(format => (
232+
formats.forEach((format) => (
234233
it(`support ${format} format`, async () => {
235234
await worker.reinitialize('eng');
236235
const { data: { text } } = await worker.recognize(canvasDOM);
@@ -241,15 +240,15 @@ describe('recognize()', () => {
241240

242241
(IS_BROWSER ? describe : describe.skip)('should read video from OffscreenCanvas (browser only)', () => {
243242
// img tag is unable to render pbm, so let's skip it.
244-
const formats = FORMATS.filter(f => f !== 'pbm');
243+
const formats = FORMATS.filter((f) => f !== 'pbm');
245244
let offscreenCanvas = null;
246245
let imageDOM = null;
247246
let idx = 0;
248247
beforeEach((done) => {
249248
imageDOM = document.createElement('img');
250249
imageDOM.setAttribute('crossOrigin', 'Anonymous');
251250
imageDOM.onload = () => {
252-
offscreenCanvas = new OffscreenCanvas(imageDOM.width, imageDOM.height)
251+
offscreenCanvas = new OffscreenCanvas(imageDOM.width, imageDOM.height);
253252
offscreenCanvas.getContext('2d').drawImage(imageDOM, 0, 0);
254253
done();
255254
};
@@ -262,7 +261,7 @@ describe('recognize()', () => {
262261
imageDOM.remove();
263262
});
264263

265-
formats.forEach(format => (
264+
formats.forEach((format) => (
266265
it(`support ${format} format`, async () => {
267266
await worker.reinitialize('eng');
268267
const { data: { text } } = await worker.recognize(offscreenCanvas);

tests/scheduler.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ before(async function cb() {
66
this.timeout(0);
77
const NUM_WORKERS = 5;
88
console.log(`Initializing ${NUM_WORKERS} workers`);
9-
workers = await Promise.all(Array(NUM_WORKERS).fill(0).map(async () => {
10-
return await createWorker("eng", 1, OPTIONS);
11-
}));
9+
workers = await Promise.all(Array(NUM_WORKERS).fill(0).map(async () => (createWorker('eng', 1, OPTIONS))));
1210
console.log(`Initialized ${NUM_WORKERS} workers`);
1311
});
1412

1513
describe('scheduler', () => {
1614
describe('should speed up with more workers (running 10 jobs)', () => {
17-
[1, 3, 5].forEach(num => (
15+
[1, 3, 5].forEach((num) => (
1816
it(`support using ${num} workers`, async () => {
1917
const NUM_JOBS = 10;
2018
const scheduler = createScheduler();

0 commit comments

Comments
 (0)