File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/components/select/__tests__ Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,20 @@ describe(`Select`, () => {
1717 < Select onClick = { handleClick } selectRef = { ref } />
1818 ) ;
1919 } ;
20- it ( `should do nothing if ref does not exist` , ( ) => {
20+
21+ it ( `should do nothing if ref does not Exist` , ( ) => {
2122 const useRefSpy = jest . spyOn ( React , 'useRef' ) . mockReturnValueOnce ( { current : null } ) ;
2223 const component = shallow ( < SelectComp /> ) ;
2324 component . find ( 'Select' ) . simulate ( 'click' ) ;
2425 expect ( useRefSpy ) . toBeCalledWith ( null ) ;
2526 } ) ;
27+
28+ it ( 'should handle DOM events where ref Exists' , ( ) => {
29+ const useRefSpy = jest . spyOn ( React , 'useRef' ) . mockReturnValueOnce ( { current : document . createElement ( 'select' ) } ) ;
30+ const mock = jest . fn ( ) ;
31+ const component = shallow ( < SelectComp onHandle = { mock } /> ) ;
32+ component . find ( 'Select' ) . simulate ( 'click' ) ;
33+ expect ( useRefSpy ) . toBeCalledWith ( null ) ;
34+ expect ( mock ) . toBeCalledTimes ( 1 ) ;
35+ } ) ;
2636} )
You can’t perform that action at this time.
0 commit comments