Skip to content

Commit

Permalink
Add test for Code39 type without checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Averin committed Sep 26, 2024
1 parent b47dc5d commit c231dba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/scanBarcode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,25 @@ describe('scanBarcode', () => {
}
);
});

it('should scan Code39 without checksum', async () => {
const request = new Barcode.ScanBarcodeRequest(fs.readFileSync('./testdata/Code39.jpg'));
request.decodeTypes = [Barcode.DecodeBarcodeType.Code39Extended];
request.checksumValidation = Barcode.ChecksumValidation.Off;
request.timeout = 5_000;

const recognized = await api.scanBarcode(request);

const barcodes = recognized.body.barcodes;
assert.ok(barcodes);
assert.strictEqual(barcodes.length, 1);

assert.strictEqual(barcodes[0].type, Barcode.DecodeBarcodeType.Code39Extended);
assert.strictEqual(barcodes[0].barcodeValue, '8M93');

assert.ok(barcodes[0].region);
assert.strictEqual(barcodes[0].region.length, 4);
assert.ok(barcodes[0].region[0].X > 0, `X=${barcodes[0].region[0].X}`);
assert.ok(barcodes[0].region[0].Y > 0, `Y=${barcodes[0].region[0].Y}`);
});
});
Binary file added testdata/Code39.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c231dba

Please sign in to comment.