2017-10-27 01:41:06 +00:00
|
|
|
const {globalShortcut} = require('electron').remote
|
2016-08-09 22:10:51 +00:00
|
|
|
|
2018-06-18 16:50:37 +00:00
|
|
|
const chai = require('chai')
|
|
|
|
const dirtyChai = require('dirty-chai')
|
2017-10-27 01:41:06 +00:00
|
|
|
const isCI = require('electron').remote.getGlobal('isCi')
|
2016-08-10 15:51:29 +00:00
|
|
|
|
2018-06-18 16:50:37 +00:00
|
|
|
const {expect} = chai
|
|
|
|
chai.use(dirtyChai)
|
|
|
|
|
2017-10-27 01:41:29 +00:00
|
|
|
describe('globalShortcut module', () => {
|
2017-11-15 21:05:46 +00:00
|
|
|
before(function () {
|
|
|
|
if (isCI && process.platform === 'win32') {
|
|
|
|
this.skip()
|
|
|
|
}
|
|
|
|
})
|
2016-08-10 15:51:29 +00:00
|
|
|
|
2016-08-09 22:10:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
globalShortcut.unregisterAll()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can register and unregister accelerators', () => {
|
|
|
|
const accelerator = 'CommandOrControl+A+B+C'
|
|
|
|
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
2016-08-09 22:10:51 +00:00
|
|
|
globalShortcut.register(accelerator, () => {})
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.true()
|
2016-08-09 22:10:51 +00:00
|
|
|
globalShortcut.unregister(accelerator)
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
2016-08-09 22:10:51 +00:00
|
|
|
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
2016-08-09 22:10:51 +00:00
|
|
|
globalShortcut.register(accelerator, () => {})
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.true()
|
2016-08-09 22:10:51 +00:00
|
|
|
globalShortcut.unregisterAll()
|
2018-06-18 16:50:37 +00:00
|
|
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
2016-08-09 22:10:51 +00:00
|
|
|
})
|
|
|
|
})
|