From 041b5493dc43c9f8b69dc5a1dde4b319638618a7 Mon Sep 17 00:00:00 2001
From: Dan Finlay <dan@danfinlay.com>
Date: Fri, 13 May 2016 01:13:14 -0700
Subject: Streamlined some transition logic

Fixes #122

Had used multiple actions for some transitions, which would lead to brief intermediary states.

Now making a few actions much more explicit about what they route to, so there is less intermediary logic, and we can transition confidently to the correct view.
---
 test/unit/actions/restore_vault_test.js        |  8 +++++++-
 test/unit/actions/set_selected_account_test.js | 21 +++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

(limited to 'test/unit')

diff --git a/test/unit/actions/restore_vault_test.js b/test/unit/actions/restore_vault_test.js
index 5675028b1..609f5429e 100644
--- a/test/unit/actions/restore_vault_test.js
+++ b/test/unit/actions/restore_vault_test.js
@@ -21,7 +21,13 @@ describe('#recoverFromSeed(password, seed)', function() {
 
   // stub out account manager
   actions._setAccountManager({
-    recoverFromSeed(pw, seed, cb) { cb(null, [{}, {}]) },
+    recoverFromSeed(pw, seed, cb) {
+      cb(null, {
+        identities: {
+          foo: 'bar'
+        }
+      })
+    },
   })
 
   it('sets metamask.isUnlocked to true', function() {
diff --git a/test/unit/actions/set_selected_account_test.js b/test/unit/actions/set_selected_account_test.js
index 0487bc5f0..69eb11e47 100644
--- a/test/unit/actions/set_selected_account_test.js
+++ b/test/unit/actions/set_selected_account_test.js
@@ -26,3 +26,24 @@ describe('SET_SELECTED_ACCOUNT', function() {
     assert.equal(resultingState.appState.activeAddress, action.value)
   });
 });
+
+describe('SHOW_ACCOUNT_DETAIL', function() {
+  it('updates metamask state', function() {
+    var initialState = {
+      metamask: {
+        selectedAccount: 'foo'
+      }
+    }
+    freeze(initialState)
+
+    const action = {
+      type: actions.SHOW_ACCOUNT_DETAIL,
+      value: 'bar',
+    }
+    freeze(action)
+
+    var resultingState = reducers(initialState, action)
+    assert.equal(resultingState.metamask.selectedAccount, action.value)
+    assert.equal(resultingState.metamask.selectedAddress, action.value)
+  })
+})
-- 
cgit v1.2.3