File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
import React , { ReactNode } from 'react' ;
2
+ import TestRenderer from 'react-test-renderer' ;
2
3
import { renderHook } from '../pure' ;
3
4
4
5
test ( 'gives comitted result' , ( ) => {
@@ -94,3 +95,20 @@ test('props type is inferred correctly when initial props is explicitly undefine
94
95
95
96
expect ( result . current ) . toBe ( 6 ) ;
96
97
} ) ;
98
+
99
+ /**
100
+ * This test makes sure that calling renderHook does
101
+ * not try to detect host component names in any form.
102
+ * But since there are numerous methods that could trigger that
103
+ * we check the count of renders using React Test Renderers.
104
+ */
105
+ test ( 'does render only once' , ( ) => {
106
+ jest . spyOn ( TestRenderer , 'create' ) ;
107
+
108
+ renderHook ( ( ) => {
109
+ const [ state , setState ] = React . useState ( 1 ) ;
110
+ return [ state , setState ] ;
111
+ } ) ;
112
+
113
+ expect ( TestRenderer . create ) . toHaveBeenCalledTimes ( 1 ) ;
114
+ } ) ;
You can’t perform that action at this time.
0 commit comments