2017-10-26 21:41:06 -04:00
|
|
|
const {globalShortcut} = require('electron').remote
|
2016-08-09 15:10:51 -07:00
|
|
|
|
2017-10-26 21:41:06 -04:00
|
|
|
const assert = require('assert')
|
|
|
|
const isCI = require('electron').remote.getGlobal('isCi')
|
2016-08-10 08:51:29 -07:00
|
|
|
|
2017-10-26 21:41:29 -04:00
|
|
|
describe('globalShortcut module', () => {
|
2017-11-16 00:05:46 +03:00
|
|
|
before(function () {
|
|
|
|
if (isCI && process.platform === 'win32') {
|
|
|
|
this.skip()
|
|
|
|
}
|
|
|
|
})
|
2016-08-10 08:51:29 -07:00
|
|
|
|
2016-08-09 15:10:51 -07:00
|
|
|
beforeEach(() => {
|
|
|
|
globalShortcut.unregisterAll()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can register and unregister accelerators', () => {
|
|
|
|
const accelerator = 'CommandOrControl+A+B+C'
|
|
|
|
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
|
|
|
globalShortcut.register(accelerator, () => {})
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), true)
|
|
|
|
globalShortcut.unregister(accelerator)
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
|
|
|
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
|
|
|
globalShortcut.register(accelerator, () => {})
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), true)
|
|
|
|
globalShortcut.unregisterAll()
|
|
|
|
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
|
|
|
})
|
|
|
|
})
|