From fd3238cf5a9c350e02ee118ee1cd3ba7282774ad Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 4 May 2017 10:59:34 -0400 Subject: [PATCH] Expose selector dependencies for testing purposes --- src/index.js | 1 + test/test_selector.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/index.js b/src/index.js index 69714c839..ab0130f52 100644 --- a/src/index.js +++ b/src/index.js @@ -79,6 +79,7 @@ export function createSelectorCreator(memoize, ...memoizeOptions) { }) selector.resultFunc = resultFunc + selector.dependencies = dependencies selector.recomputations = () => recomputations selector.resetRecomputations = () => recomputations = 0 return selector diff --git a/test/test_selector.js b/test/test_selector.js index 60d6dbcac..c91871871 100644 --- a/test/test_selector.js +++ b/test/test_selector.js @@ -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 + ]) + }) })