From a6353eb98f6cd045bdf246bcbaa37adbdea60303 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 9 Aug 2016 15:10:51 -0700 Subject: [PATCH] Add initial global shortcut spec --- spec/api-global-shortcut-spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/api-global-shortcut-spec.js diff --git a/spec/api-global-shortcut-spec.js b/spec/api-global-shortcut-spec.js new file mode 100644 index 000000000000..d4f277496c60 --- /dev/null +++ b/spec/api-global-shortcut-spec.js @@ -0,0 +1,24 @@ +const {globalShortcut} = require('electron').remote +const assert = require('assert') + +describe('globalShortcut module', () => { + 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) + }) +})