Skip to content

Commit

Permalink
Merge pull request #251 from jimbol/expose-dependencies
Browse files Browse the repository at this point in the history
Expose selector dependencies for testing purposes
  • Loading branch information
ellbee authored Jun 22, 2018
2 parents 29851a0 + fd3238c commit 59456cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function createSelectorCreator(memoize, ...memoizeOptions) {
})

selector.resultFunc = resultFunc
selector.dependencies = dependencies
selector.recomputations = () => recomputations
selector.resetRecomputations = () => recomputations = 0
return selector
Expand Down
14 changes: 14 additions & 0 deletions test/test_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,18 @@ suite('selector', () => {
)
assert.equal(selector.resultFunc, lastFunction)
})
test('export dependencies as dependencies', () => {
const dependency1 = (state) => { state.a }
const dependency2 = (state) => { state.a }

const selector = createSelector(
dependency1,
dependency2,
() => {}
)
assert.deepEqual(selector.dependencies, [
dependency1,
dependency2
])
})
})

0 comments on commit 59456cd

Please sign in to comment.