|
1 | 1 | import type { ReactNode } from 'react'; |
2 | | -import React from 'react'; |
3 | | -import TestRenderer from 'universal-test-renderer'; |
| 2 | +import * as React from 'react'; |
| 3 | +import * as UniversalTestRenderer from 'universal-test-renderer'; |
4 | 4 |
|
5 | 5 | import { renderHook } from '../pure'; |
6 | 6 |
|
@@ -85,20 +85,19 @@ test('props type is inferred correctly when initial props is explicitly undefine |
85 | 85 | expect(result.current.param).toBe(6); |
86 | 86 | }); |
87 | 87 |
|
88 | | -// TEMP |
89 | | -// /** |
90 | | -// * This test makes sure that calling renderHook does |
91 | | -// * not try to detect host component names in any form. |
92 | | -// * But since there are numerous methods that could trigger that |
93 | | -// * we check the count of renders using React Test Renderers. |
94 | | -// */ |
95 | | -// test('does render only once', () => { |
96 | | -// jest.spyOn(TestRenderer, 'create'); |
97 | | - |
98 | | -// renderHook(() => { |
99 | | -// const [state, setState] = React.useState(1); |
100 | | -// return [state, setState]; |
101 | | -// }); |
102 | | - |
103 | | -// expect(TestRenderer.create).toHaveBeenCalledTimes(1); |
104 | | -// }); |
| 88 | +/** |
| 89 | + * This test makes sure that calling renderHook does |
| 90 | + * not try to detect host component names in any form. |
| 91 | + * But since there are numerous methods that could trigger that |
| 92 | + * we check the count of renders using React Test Renderers. |
| 93 | + */ |
| 94 | +test('does render only once', () => { |
| 95 | + jest.spyOn(UniversalTestRenderer, 'createRoot'); |
| 96 | + |
| 97 | + renderHook(() => { |
| 98 | + const [state, setState] = React.useState(1); |
| 99 | + return [state, setState]; |
| 100 | + }); |
| 101 | + |
| 102 | + expect(UniversalTestRenderer.createRoot).toHaveBeenCalledTimes(1); |
| 103 | +}); |
0 commit comments