Browse Source

add support for stubbing out getUserMedia for now..

main
John-Mark Gurney 4 years ago
parent
commit
32ef35d06c
2 changed files with 27 additions and 0 deletions
  1. +1
    -0
      package.json
  2. +26
    -0
      src/index/index.spec.js

+ 1
- 0
package.json View File

@@ -38,6 +38,7 @@
"chai": "^4.2.0",
"mocha": "^7.1.1",
"nyc": "^15.0.1",
"sinon": "^9.0.2",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},


+ 26
- 0
src/index/index.spec.js View File

@@ -1,12 +1,38 @@
'use strict'

const sinon = require('sinon')
const index = require('../index')
const expect = require('chai').expect

var navigator;

function setupBrowser() {
navigator = {
mediaDevices: {
getUserMedia: () => { console.log('dummy'); throw 'failure'; }
}
}
global.navigator = navigator;
}

describe('index module', () => {
describe('"members"', () => {
it('should be have the following members', () => {
expect(global.runPage).to.be.a('function');
})
})
describe('"runPage"', () => {
it('should call getUserMedia', async () => {
setupBrowser();

var gum = sinon.stub(navigator.mediaDevices, 'getUserMedia');
gum.onFirstCall().returns(true);

await global.runPage();

expect(gum.calledOnce).to.be.true;

gum.restore();
})
})
})

Loading…
Cancel
Save