mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
merged master; fixed tests
This commit is contained in:
@@ -53,7 +53,8 @@ describe('decodeSingle', function () {
|
||||
expect(result.codeResult.code).to.equal(sample.result);
|
||||
expect(result.codeResult.format).to.equal(sample.format);
|
||||
callback();
|
||||
});
|
||||
})
|
||||
.start();
|
||||
}, function() {
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BarcodeLocator from '../../src/locator/barcode_locator';
|
||||
import {checkImageConstraints} from '../../src/locator/barcode_locator';
|
||||
import Config from '../../src/config/config';
|
||||
import {merge} from 'lodash';
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('checkImageConstraints', function() {
|
||||
|
||||
it('should not adjust the image-size if not needed', function() {
|
||||
var expected = {x: imageSize.x, y: imageSize.y};
|
||||
BarcodeLocator.checkImageConstraints(inputStream, config.locator);
|
||||
checkImageConstraints(inputStream, config.locator);
|
||||
expect(inputStream.getWidth()).to.be.equal(expected.x);
|
||||
expect(inputStream.getHeight()).to.be.equal(expected.y);
|
||||
});
|
||||
@@ -55,7 +55,7 @@ describe('checkImageConstraints', function() {
|
||||
|
||||
config.locator.halfSample = true;
|
||||
imageSize.y += 1;
|
||||
BarcodeLocator.checkImageConstraints(inputStream, config.locator);
|
||||
checkImageConstraints(inputStream, config.locator);
|
||||
expect(inputStream.getWidth()).to.be.equal(expected.x);
|
||||
expect(inputStream.getHeight()).to.be.equal(expected.y);
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('checkImageConstraints', function() {
|
||||
|
||||
imageSize.y += 1;
|
||||
config.locator.halfSample = false;
|
||||
BarcodeLocator.checkImageConstraints(inputStream, config.locator);
|
||||
checkImageConstraints(inputStream, config.locator);
|
||||
expect(inputStream.getHeight()).to.be.equal(expected.y);
|
||||
expect(inputStream.getWidth()).to.be.equal(expected.x);
|
||||
});
|
||||
@@ -92,7 +92,7 @@ describe('checkImageConstraints', function() {
|
||||
};
|
||||
|
||||
config.locator.halfSample = false;
|
||||
BarcodeLocator.checkImageConstraints(inputStream, config.locator);
|
||||
checkImageConstraints(inputStream, config.locator);
|
||||
expect(inputStream.getHeight()).to.be.equal(expectedSize.y);
|
||||
expect(inputStream.getWidth()).to.be.equal(expectedSize.x);
|
||||
expect(inputStream.setTopRight.getCall(0).args[0]).to.deep.equal(expectedTopRight);
|
||||
@@ -121,7 +121,7 @@ describe('checkImageConstraints', function() {
|
||||
};
|
||||
|
||||
config.locator.halfSample = false;
|
||||
BarcodeLocator.checkImageConstraints(inputStream, config.locator);
|
||||
checkImageConstraints(inputStream, config.locator);
|
||||
expect(inputStream.getHeight()).to.be.equal(expectedSize.y);
|
||||
expect(inputStream.getWidth()).to.be.equal(expectedSize.x);
|
||||
expect(inputStream.setTopRight.getCall(0).args[0]).to.deep.equal(expectedTopRight);
|
||||
|
||||
@@ -27,9 +27,10 @@ beforeEach(function() {
|
||||
sinon.spy(tracks[0], "stop");
|
||||
|
||||
video = {
|
||||
src: null,
|
||||
srcObject: null,
|
||||
addEventListener: function() {},
|
||||
removeEventListener: function() {},
|
||||
setAttribute: sinon.spy(),
|
||||
play: function() {},
|
||||
videoWidth: 320,
|
||||
videoHeight: 480
|
||||
@@ -60,12 +61,9 @@ describe('success', function() {
|
||||
CameraAccess.request(video, {})
|
||||
.then(function () {
|
||||
expect(navigator.mediaDevices.getUserMedia.calledOnce).to.equal(true);
|
||||
expect(video.src).to.deep.equal(stream);
|
||||
expect(video.srcObject).to.deep.equal(stream);
|
||||
done();
|
||||
})
|
||||
window.setTimeout(() => {
|
||||
video.onloadedmetadata();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it("should allow deprecated constraints to be used", (done) => {
|
||||
@@ -89,9 +87,6 @@ describe('success', function() {
|
||||
expect(args[0].video.maxAspectRatio).not.to.be.defined;
|
||||
done();
|
||||
})
|
||||
window.setTimeout(() => {
|
||||
video.onloadedmetadata();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -122,9 +117,6 @@ describe('success', function() {
|
||||
expect(args[0].video.deviceId).to.equal("user");
|
||||
done();
|
||||
})
|
||||
window.setTimeout(() => {
|
||||
video.onloadedmetadata();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,15 +124,12 @@ describe('success', function() {
|
||||
it('should release the camera', function (done) {
|
||||
CameraAccess.request(video, {})
|
||||
.then(function () {
|
||||
expect(video.src).to.deep.equal(stream);
|
||||
expect(video.srcObject).to.deep.equal(stream);
|
||||
CameraAccess.release();
|
||||
expect(video.src.getVideoTracks()).to.have.length(1);
|
||||
expect(video.src.getVideoTracks()[0].stop.calledOnce).to.equal(true);
|
||||
expect(video.srcObject.getVideoTracks()).to.have.length(1);
|
||||
expect(video.srcObject.getVideoTracks()[0].stop.calledOnce).to.equal(true);
|
||||
done();
|
||||
});
|
||||
window.setTimeout(() => {
|
||||
video.onloadedmetadata();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import Events from '../../src/common/events';
|
||||
import createEventedElement from '../../src/common/events';
|
||||
|
||||
let Events;
|
||||
beforeEach(function() {
|
||||
Events.unsubscribe();
|
||||
Events = createEventedElement();
|
||||
});
|
||||
describe("subscribe", function() {
|
||||
|
||||
|
||||
it("should call one callback for a single event", function() {
|
||||
var callbackA = sinon.stub(),
|
||||
callbackB = sinon.stub();
|
||||
@@ -31,18 +30,16 @@ describe("subscribe", function() {
|
||||
|
||||
it("should call the callback asynchronuously", function(done) {
|
||||
var test = {
|
||||
callback: function() {
|
||||
|
||||
}
|
||||
};
|
||||
callback: function() {}
|
||||
};
|
||||
|
||||
sinon.stub(test, "callback", function() {
|
||||
expect(test.callback.calledOnce).to.be.true;
|
||||
expect(test.callback.calledOnce).to.equal(true);
|
||||
done();
|
||||
});
|
||||
Events.subscribe("test", test.callback, true);
|
||||
Events.publish("test");
|
||||
expect(test.callback.called).to.be.false;
|
||||
expect(test.callback.called).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user