Skip to content

Commit

Permalink
Fix: use getter for canvas property on Quagga object, 0.0.21
Browse files Browse the repository at this point in the history
- also add test for canvas properties
  • Loading branch information
ericblade committed Apr 26, 2020
1 parent ee70a74 commit 2ea50c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ericblade/quagga2",
"version": "0.0.20",
"version": "0.0.21",
"description": "An advanced barcode-scanner written in JavaScript",
"main": "lib/quagga.js",
"types": "type-definitions/quagga.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/quagga.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ export default {
_context.resultCollector = resultCollector;
}
},
canvas: _context.canvasContainer,
get canvas() {
return _context.canvasContainer;
},
decodeSingle: function (config, resultCallback) {
if (this.inDecodeSingle) {
// force multiple calls to decodeSingle to run in serial, because presently
Expand Down
10 changes: 9 additions & 1 deletion test/integration/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ describe('decodeSingle', function () {
expect(result.codeResult.code).to.equal(sample.result);
console.warn(`* Expect ${result.codeResult.format} to equal ${sample.format}`);
expect(result.codeResult.format).to.equal(sample.format);
console.warn(`* Expect Quagga.canvas to be an object ${Quagga.canvas}`);
expect(Quagga.canvas).to.be.an('Object');
console.warn(`* Expect Quagga.canvas.dom to be an object ${Quagga.canvas.dom}`);
expect(Quagga.canvas.dom).to.be.an('Object');
console.warn(`* Expect Quagga.canvas.ctx to be an object ${Quagga.canvas.ctx}`);
expect(Quagga.canvas.ctx).to.be.an('Object');
console.warn(`* Expect Quagga.canvas.ctx.overlay to be a CanvasRenderingContext2D ${Quagga.canvas.ctx.overlay}`);
expect(Quagga.canvas.ctx.overlay).to.be.an('CanvasRenderingContext2D');
callback();
});
}, function() {
Expand Down Expand Up @@ -120,7 +128,7 @@ describe('decodeSingle', function () {

// TODO: write a test that tests Promise return/resolve

describe('EAN', function() {
describe.only('EAN', function() {
var config = generateConfig(),
testSet = [
{'name': 'image-001.jpg', 'result': '3574660239843'},
Expand Down

0 comments on commit 2ea50c4

Please sign in to comment.