From 2d737552222e3405f9e54e14e7602cc37a3874bd Mon Sep 17 00:00:00 2001 From: bridiver Date: Mon, 12 Jun 2017 15:57:46 -0700 Subject: [PATCH 1/2] =?UTF-8?q?don=E2=80=99t=20convert=20paths=20to=20immu?= =?UTF-8?q?table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/state/tabState.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/common/state/tabState.js b/app/common/state/tabState.js index 07cf660b7e1..de01c258c1d 100644 --- a/app/common/state/tabState.js +++ b/app/common/state/tabState.js @@ -280,7 +280,7 @@ const tabState = { if (index === tabState.TAB_ID_NONE) { return null } - return makeImmutable(['tabs', index]) + return ['tabs', index] }, getByTabId: (state, tabId) => { @@ -534,7 +534,7 @@ const tabState = { if (path == null) { return null } - return path.push('frame') + return path.concat(['frame']) } else { return frameState.getPathByTabId(state, tabId) } @@ -603,13 +603,13 @@ const tabState = { if (!tabValue) { return state } - const path = tabState.getPathByTabId(state, tabId).push('navigationState') - return state.setIn(path, navigationState) + const path = tabState.getPathByTabId(state, tabId) + return path ? state.setIn(path.concat(['navigationState']), navigationState) : state }, getNavigationState: (state, tabId) => { const path = tabState.getPathByTabId(state, tabId) - return path ? state.getIn(path.push('navigationState'), Immutable.Map()) : null + return path ? state.getIn(path.concat(['navigationState']), Immutable.Map()) : null }, getVisibleEntry: (state, tabId) => { From ecdb12c2293d794aa84343c0184a9dd0131474e2 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Wed, 14 Jun 2017 23:20:56 -0700 Subject: [PATCH 2/2] Added unit tests for `getPathByTabId` in tabState Auditors: @bridiver --- test/unit/app/common/state/tabStateTest.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/app/common/state/tabStateTest.js b/test/unit/app/common/state/tabStateTest.js index 56fdc6ed70e..a530f179351 100644 --- a/test/unit/app/common/state/tabStateTest.js +++ b/test/unit/app/common/state/tabStateTest.js @@ -195,6 +195,15 @@ const shouldValidateAction = function (cb) { } describe('tabState unit tests', function () { + describe('getPathByTabId', function () { + it('returns null if tab is not found', function () { + assert.equal(tabState.getPathByTabId(twoTabsAppState, 333), null) + }) + it('returns path if index found (as mutable array)', function () { + assert.deepEqual(tabState.getPathByTabId(twoTabsAppState, 1), ['tabs', 0]) + }) + }) + describe('getByTabId', function () { before(function () { this.appState = twoTabsAppState