aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-08-23 02:58:17 +0800
committerGitHub <noreply@github.com>2018-08-23 02:58:17 +0800
commit171f6711d988cdfe04badee6f1b445a3abf513ad (patch)
tree7844a2eb8e5dfa3487f3f204a923600c3ca59456 /test
parent21a6fdc1748424e84d12156552d344c622c03dd1 (diff)
parente803b8e047b5acad9143fe28d99d9e7d65211f46 (diff)
downloadtangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar.gz
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar.bz2
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar.lz
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar.xz
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.tar.zst
tangerine-wallet-browser-171f6711d988cdfe04badee6f1b445a3abf513ad.zip
Merge pull request #5066 from whymarrh/fix-key-export
Don't re-render the export modal when the selected identity changes
Diffstat (limited to 'test')
-rw-r--r--test/unit/app/controllers/metamask-controller-test.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js
index a798d41e2..85c78fe1e 100644
--- a/test/unit/app/controllers/metamask-controller-test.js
+++ b/test/unit/app/controllers/metamask-controller-test.js
@@ -814,6 +814,77 @@ describe('MetaMaskController', function () {
})
})
+ describe('#_onKeyringControllerUpdate', function () {
+ it('should do nothing if there are no keyrings in state', async function () {
+ const addAddresses = sinon.fake()
+ const syncWithAddresses = sinon.fake()
+ sandbox.replace(metamaskController, 'preferencesController', {
+ addAddresses,
+ })
+ sandbox.replace(metamaskController, 'accountTracker', {
+ syncWithAddresses,
+ })
+
+ const oldState = metamaskController.getState()
+ await metamaskController._onKeyringControllerUpdate({keyrings: []})
+
+ assert.ok(addAddresses.notCalled)
+ assert.ok(syncWithAddresses.notCalled)
+ assert.deepEqual(metamaskController.getState(), oldState)
+ })
+
+ it('should update selected address if keyrings was locked', async function () {
+ const addAddresses = sinon.fake()
+ const getSelectedAddress = sinon.fake.returns('0x42')
+ const setSelectedAddress = sinon.fake()
+ const syncWithAddresses = sinon.fake()
+ sandbox.replace(metamaskController, 'preferencesController', {
+ addAddresses,
+ getSelectedAddress,
+ setSelectedAddress,
+ })
+ sandbox.replace(metamaskController, 'accountTracker', {
+ syncWithAddresses,
+ })
+
+ const oldState = metamaskController.getState()
+ await metamaskController._onKeyringControllerUpdate({
+ isUnlocked: false,
+ keyrings: [{
+ accounts: ['0x1', '0x2'],
+ }],
+ })
+
+ assert.deepEqual(addAddresses.args, [[['0x1', '0x2']]])
+ assert.deepEqual(syncWithAddresses.args, [[['0x1', '0x2']]])
+ assert.deepEqual(setSelectedAddress.args, [['0x1']])
+ assert.deepEqual(metamaskController.getState(), oldState)
+ })
+
+ it('should NOT update selected address if already unlocked', async function () {
+ const addAddresses = sinon.fake()
+ const syncWithAddresses = sinon.fake()
+ sandbox.replace(metamaskController, 'preferencesController', {
+ addAddresses,
+ })
+ sandbox.replace(metamaskController, 'accountTracker', {
+ syncWithAddresses,
+ })
+
+ const oldState = metamaskController.getState()
+ await metamaskController._onKeyringControllerUpdate({
+ isUnlocked: true,
+ keyrings: [{
+ accounts: ['0x1', '0x2'],
+ }],
+ })
+
+ assert.deepEqual(addAddresses.args, [[['0x1', '0x2']]])
+ assert.deepEqual(syncWithAddresses.args, [[['0x1', '0x2']]])
+ assert.deepEqual(metamaskController.getState(), oldState)
+ })
+ })
+
})
function deferredPromise () {