fixed unit tests

feature/default_network_editable
brunobar79 6 years ago
parent 53dcad5a3b
commit fdf202efb0
  1. 6
      app/scripts/metamask-controller.js
  2. 14
      test/unit/app/controllers/metamask-controller-test.js

@ -551,15 +551,21 @@ module.exports = class MetamaskController extends EventEmitter {
default:
throw new Error('MetamaskController:getKeyringForDevice - Unknown device')
}
console.log('getting keyring for device ', deviceName, hdPath)
let keyring = await this.keyringController.getKeyringsByType(keyringName)[0]
console.log('got Keyring', keyring)
if (!keyring) {
console.log('we did not so lets add it', keyringName)
keyring = await this.keyringController.addNewKeyring(keyringName)
console.log('what about now', keyring)
}
console.log('setting hdPath', hdPath)
if (hdPath && keyring.setHdPath) {
keyring.setHdPath(hdPath)
}
keyring.network = this.networkController.getProviderConfig().type
console.log('setting network', keyring.network)
return keyring

@ -315,16 +315,20 @@ describe('MetaMaskController', function () {
sinon.spy(metamaskController.preferencesController, 'setAddresses')
sinon.spy(metamaskController.preferencesController, 'setSelectedAddress')
sinon.spy(metamaskController.preferencesController, 'setAccountLabel')
await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`)
await metamaskController.unlockHardwareWalletAccount('trezor', accountToUnlock, `m/44/0'/0'`)
await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`).catch((e) => null)
await metamaskController.unlockHardwareWalletAccount(accountToUnlock, 'trezor', `m/44/0'/0'`)
})
afterEach(function () {
metamaskController.keyringController.addNewAccount.restore()
window.open.restore()
metamaskController.keyringController.addNewAccount.restore()
metamaskController.keyringController.getAccounts.restore()
metamaskController.preferencesController.setAddresses.restore()
metamaskController.preferencesController.setSelectedAddress.restore()
metamaskController.preferencesController.setAccountLabel.restore()
})
it('should set accountToUnlock in the keyring', async function () {
it('should set unlockedAccount in the keyring', async function () {
const keyrings = await metamaskController.keyringController.getKeyringsByType(
'Trezor Hardware'
)
@ -332,7 +336,7 @@ describe('MetaMaskController', function () {
})
it('should call keyringController.addNewAccount', async function () {
it('should call keyringController.addNewAccount', async function () {
assert(metamaskController.keyringController.addNewAccount.calledOnce)
})

Loading…
Cancel
Save