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

Commit

Permalink
Merge pull request #9468 from brave/state-paths
Browse files Browse the repository at this point in the history
don’t convert paths to immutable
  • Loading branch information
bsclifton authored Jun 15, 2017
2 parents ed4824b + ecdb12c commit dc534ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit dc534ed

Please sign in to comment.