aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-17 07:36:08 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-17 07:36:08 +0800
commite5512c306ded1d2a521a0ba0d2c3cdd5878e53bb (patch)
treeaad8b2e2fa6641f1e3a66b687aca22402d2507a8 /test
parent41879a983582c832fe3b6b19df3c057a1cc13d2a (diff)
downloadtangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.gz
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.bz2
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.lz
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.xz
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.zst
tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.zip
added unit tests for metamaskcontroller
Diffstat (limited to 'test')
-rw-r--r--test/unit/app/controllers/metamask-controller-test.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js
index 0dda4609b..bef126f1f 100644
--- a/test/unit/app/controllers/metamask-controller-test.js
+++ b/test/unit/app/controllers/metamask-controller-test.js
@@ -222,6 +222,76 @@ describe('MetaMaskController', function () {
})
})
+ describe('connectHardware', function () {
+
+ it('should throw if it receives an unknown device name', async function () {
+ try {
+ await metamaskController.connectHardware('Some random device name', 0)
+ } catch (e) {
+ assert.equal(e, 'Error: MetamaskController:connectHardware - Unknown device')
+ }
+ })
+
+ it('should add the Trezor Hardware keyring', async function () {
+ await metamaskController.connectHardware('trezor', 0).catch((e) => null)
+ const keyrings = await metamaskController.keyringController.getKeyringsByType(
+ 'Trezor Hardware'
+ )
+ assert.equal(keyrings.length, 1)
+ })
+
+ })
+
+ describe('checkHardwareStatus', function () {
+ it('should throw if it receives an unknown device name', async function () {
+ try {
+ await metamaskController.checkHardwareStatus('Some random device name')
+ } catch (e) {
+ assert.equal(e, 'Error: MetamaskController:checkHardwareStatus - Unknown device')
+ }
+ })
+
+ it('should be locked by default', async function () {
+ await metamaskController.connectHardware('trezor', 0).catch((e) => null)
+ const status = await metamaskController.checkHardwareStatus('trezor')
+ assert.equal(status, false)
+ })
+ })
+
+ describe('forgetDevice', function () {
+ it('should throw if it receives an unknown device name', async function () {
+ try {
+ await metamaskController.forgetDevice('Some random device name')
+ } catch (e) {
+ assert.equal(e, 'Error: MetamaskController:forgetDevice - Unknown device')
+ }
+ })
+
+ it('should wipe all the keyring info', async function () {
+ await metamaskController.connectHardware('trezor', 0).catch((e) => null)
+ await metamaskController.forgetDevice('trezor')
+ const keyrings = await metamaskController.keyringController.getKeyringsByType(
+ 'Trezor Hardware'
+ )
+
+ assert.deepEqual(keyrings[0].accounts, [])
+ assert.deepEqual(keyrings[0].page, 0)
+ assert.deepEqual(keyrings[0].isUnlocked(), false)
+ })
+ })
+
+ describe('unlockTrezorAccount', function () {
+ it('should set accountToUnlock in the keyring', async function () {
+ await metamaskController.connectHardware('trezor', 0).catch((e) => null)
+ const accountToUnlock = 10
+ await metamaskController.unlockTrezorAccount(accountToUnlock).catch((e) => null)
+ const keyrings = await metamaskController.keyringController.getKeyringsByType(
+ 'Trezor Hardware'
+ )
+ assert.equal(keyrings[0].unlockedAccount, accountToUnlock)
+ })
+ })
+
describe('#setCustomRpc', function () {
const customRPC = 'https://custom.rpc/'
let rpcTarget