From e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 16 Jul 2018 19:36:08 -0400 Subject: added unit tests for metamaskcontroller --- app/scripts/metamask-controller.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b8b7c38e4..2f114e9f0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -561,10 +561,15 @@ module.exports = class MetamaskController extends EventEmitter { return accounts default: - throw new Error('MetamaskController - Unknown device') + throw new Error('MetamaskController:connectHardware - Unknown device') } } + /** + * Check if the device is unlocked + * + * @returns {Promise} + */ async checkHardwareStatus (deviceName) { switch (deviceName) { @@ -574,12 +579,19 @@ module.exports = class MetamaskController extends EventEmitter { 'Trezor Hardware' )[0] if (!keyring) { - return false + throw new Error('MetamaskController:checkHardwareStatus - Trezor Hardware keyring not found') } return keyring.isUnlocked() + default: + throw new Error('MetamaskController:checkHardwareStatus - Unknown device') } } + /** + * Clear + * + * @returns {Promise} + */ async forgetDevice (deviceName) { switch (deviceName) { @@ -589,10 +601,12 @@ module.exports = class MetamaskController extends EventEmitter { 'Trezor Hardware' )[0] if (!keyring) { - return false + throw new Error('MetamaskController:forgetDevice - Trezor Hardware keyring not found') } keyring.forgetDevice() return true + default: + throw new Error('MetamaskController:forgetDevice - Unknown device') } } -- cgit v1.2.3