@@ -26,7 +26,7 @@ import type {
26
26
} from '../../src/index'
27
27
import type { FunctionComponent , DispatchWithoutAction , ReactNode } from 'react'
28
28
import type { Store , AnyAction } from 'redux'
29
- import { StabilityCheck , UseSelectorOptions } from '../../src/hooks/useSelector'
29
+ import { UseSelectorOptions } from '../../src/hooks/useSelector'
30
30
31
31
// most of these tests depend on selectors being run once, which stabilityCheck doesn't do
32
32
// rather than specify it every time, let's make a new "default" here
@@ -757,8 +757,8 @@ describe('React', () => {
757
757
selector,
758
758
options,
759
759
} : {
760
- selector : ( state : NormalStateType ) => number
761
- options ?: UseSelectorOptions < number >
760
+ selector : ( state : NormalStateType ) => unknown
761
+ options ?: UseSelectorOptions < unknown >
762
762
} ) => {
763
763
useSelector ( selector , options )
764
764
return null
@@ -800,6 +800,23 @@ describe('React', () => {
800
800
} )
801
801
)
802
802
} )
803
+ it ( 'uses provided equalityFn' , ( ) => {
804
+ const unstableSelector = jest . fn ( ( state : NormalStateType ) => ( {
805
+ count : state . count ,
806
+ } ) )
807
+
808
+ rtl . render (
809
+ < Provider store = { normalStore } >
810
+ < RenderSelector
811
+ selector = { unstableSelector }
812
+ options = { { equalityFn : shallowEqual } }
813
+ />
814
+ </ Provider >
815
+ )
816
+
817
+ expect ( unstableSelector ) . toHaveBeenCalledTimes ( 2 )
818
+ expect ( consoleSpy ) . not . toHaveBeenCalled ( )
819
+ } )
803
820
it ( 'by default will only check on first selector call' , ( ) => {
804
821
rtl . render (
805
822
< Provider store = { normalStore } >
0 commit comments