update desktop capturer spec

This commit is contained in:
Shelley Vohr 2017-10-26 20:44:06 -04:00
parent 6cd308f9ad
commit 6feff1d6e8
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -1,33 +1,31 @@
const assert = require('assert') const assert = require('assert')
const desktopCapturer = require('electron').desktopCapturer const {desktopCapturer, remote} = require('electron')
const isCI = require('electron').remote.getGlobal('isCi') const isCI = remote.getGlobal('isCi')
describe('desktopCapturer', function () { describe('desktopCapturer', () => {
if (isCI && process.platform === 'win32') { if (isCI && process.platform === 'win32') return
return
}
it('should return a non-empty array of sources', function (done) { it('should return a non-empty array of sources', (done) => {
desktopCapturer.getSources({ desktopCapturer.getSources({
types: ['window', 'screen'] types: ['window', 'screen']
}, function (error, sources) { }, (error, sources) => {
assert.equal(error, null) assert.equal(error, null)
assert.notEqual(sources.length, 0) assert.notEqual(sources.length, 0)
done() done()
}) })
}) })
it('throws an error for invalid options', function (done) { it('throws an error for invalid options', (done) => {
desktopCapturer.getSources(['window', 'screen'], function (error) { desktopCapturer.getSources(['window', 'screen'], (error) => {
assert.equal(error.message, 'Invalid options') assert.equal(error.message, 'Invalid options')
done() done()
}) })
}) })
it('does not throw an error when called more than once (regression)', function (done) { it('does not throw an error when called more than once (regression)', (done) => {
var callCount = 0 let callCount = 0
var callback = function (error, sources) { const callback = (error, sources) => {
callCount++ callCount++
assert.equal(error, null) assert.equal(error, null)
assert.notEqual(sources.length, 0) assert.notEqual(sources.length, 0)
@ -38,9 +36,9 @@ describe('desktopCapturer', function () {
desktopCapturer.getSources({types: ['window', 'screen']}, callback) desktopCapturer.getSources({types: ['window', 'screen']}, callback)
}) })
it('responds to subsequest calls of different options', function (done) { it('responds to subsequest calls of different options', (done) => {
var callCount = 0 let callCount = 0
var callback = function (error, sources) { const callback = (error, sources) => {
callCount++ callCount++
assert.equal(error, null) assert.equal(error, null)
if (callCount === 2) done() if (callCount === 2) done()