forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-global-shortcut-spec.js
32 lines (26 loc) · 1.02 KB
/
api-global-shortcut-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {globalShortcut} = require('electron').remote
const assert = require('assert')
const isCI = require('electron').remote.getGlobal('isCi')
describe('globalShortcut module', () => {
before(function () {
if (isCI && process.platform === 'win32') {
this.skip()
}
})
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)
})
})