|
|
|
@ -5,7 +5,8 @@ var originalURL,
|
|
|
|
|
video,
|
|
|
|
|
stream;
|
|
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
describe("CameraAccess", () => {
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
var tracks = [{
|
|
|
|
|
stop: function() {}
|
|
|
|
|
}];
|
|
|
|
@ -14,7 +15,7 @@ beforeEach(function() {
|
|
|
|
|
originalMediaStreamTrack = window.MediaStreamTrack;
|
|
|
|
|
window.MediaStreamTrack = {};
|
|
|
|
|
window.URL = {
|
|
|
|
|
createObjectURL(stream) {
|
|
|
|
|
createObjectURL() {
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -39,14 +40,14 @@ beforeEach(function() {
|
|
|
|
|
cb();
|
|
|
|
|
});
|
|
|
|
|
sinon.stub(video, "play");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
window.URL = originalURL;
|
|
|
|
|
window.MediaStreamTrack = originalMediaStreamTrack;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('success', function() {
|
|
|
|
|
describe('success', function() {
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
sinon.stub(navigator.mediaDevices, "getUserMedia", function(constraints) {
|
|
|
|
|
return Promise.resolve(stream);
|
|
|
|
@ -63,7 +64,7 @@ describe('success', function() {
|
|
|
|
|
expect(navigator.mediaDevices.getUserMedia.calledOnce).to.equal(true);
|
|
|
|
|
expect(video.srcObject).to.deep.equal(stream);
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should allow deprecated constraints to be used", (done) => {
|
|
|
|
@ -86,7 +87,7 @@ describe('success', function() {
|
|
|
|
|
expect(args[0].video.minAspectRatio).not.to.be.defined;
|
|
|
|
|
expect(args[0].video.maxAspectRatio).not.to.be.defined;
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -103,7 +104,7 @@ describe('success', function() {
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
window.MediaStreamTrack = {};
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should set deviceId in case facingMode is not supported", (done) => {
|
|
|
|
|
CameraAccess.request(video, {
|
|
|
|
@ -116,7 +117,7 @@ describe('success', function() {
|
|
|
|
|
expect(args[0].video.facingMode).not.to.be.defined;
|
|
|
|
|
expect(args[0].video.deviceId).to.equal("user");
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -132,9 +133,9 @@ describe('success', function() {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('failure', function() {
|
|
|
|
|
describe('failure', function() {
|
|
|
|
|
describe("permission denied", function(){
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
sinon.stub(navigator.mediaDevices, "getUserMedia", function(constraints, success, failure) {
|
|
|
|
@ -175,4 +176,5 @@ describe('failure', function() {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|