Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

don’t convert paths to immutable #9468

Merged
merged 2 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/common/state/tabState.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const tabState = {
if (index === tabState.TAB_ID_NONE) {
return null
}
return makeImmutable(['tabs', index])
return ['tabs', index]
},

getByTabId: (state, tabId) => {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) => {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/app/common/state/tabStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down