77 * @flow
88 */
99
10+ import { getVersionedRenderImplementation } from './utils' ;
11+
1012describe ( 'useEditableValue' , ( ) => {
1113 let act ;
1214 let React ;
13- let legacyRender ;
1415 let useEditableValue ;
1516
1617 beforeEach ( ( ) => {
1718 const utils = require ( './utils' ) ;
1819 act = utils . act ;
19- legacyRender = utils . legacyRender ;
2020
2121 React = require ( 'react' ) ;
2222
2323 useEditableValue = require ( '../devtools/views/hooks' ) . useEditableValue ;
2424 } ) ;
2525
26+ const { render} = getVersionedRenderImplementation ( ) ;
27+
2628 it ( 'should not cause a loop with values like NaN' , ( ) => {
2729 let state ;
2830
@@ -32,8 +34,8 @@ describe('useEditableValue', () => {
3234 return null ;
3335 }
3436
35- const container = document . createElement ( 'div' ) ;
36- legacyRender ( < Example /> , container ) ;
37+ act ( ( ) => render ( < Example /> ) ) ;
38+
3739 expect ( state . editableValue ) . toEqual ( 'NaN' ) ;
3840 expect ( state . externalValue ) . toEqual ( NaN ) ;
3941 expect ( state . parsedValue ) . toEqual ( NaN ) ;
@@ -50,8 +52,8 @@ describe('useEditableValue', () => {
5052 return null ;
5153 }
5254
53- const container = document . createElement ( 'div' ) ;
54- legacyRender ( < Example value = { 1 } /> , container ) ;
55+ act ( ( ) => render ( < Example value = { 1 } /> ) ) ;
56+
5557 expect ( state . editableValue ) . toEqual ( '1' ) ;
5658 expect ( state . externalValue ) . toEqual ( 1 ) ;
5759 expect ( state . parsedValue ) . toEqual ( 1 ) ;
@@ -60,7 +62,8 @@ describe('useEditableValue', () => {
6062
6163 // If there are NO pending changes,
6264 // an update to the external prop value should override the local/pending value.
63- legacyRender ( < Example value = { 2 } /> , container ) ;
65+ act ( ( ) => render ( < Example value = { 2 } /> ) ) ;
66+
6467 expect ( state . editableValue ) . toEqual ( '2' ) ;
6568 expect ( state . externalValue ) . toEqual ( 2 ) ;
6669 expect ( state . parsedValue ) . toEqual ( 2 ) ;
@@ -78,8 +81,8 @@ describe('useEditableValue', () => {
7881 return null ;
7982 }
8083
81- const container = document . createElement ( 'div' ) ;
82- legacyRender ( < Example value = { 1 } /> , container ) ;
84+ act ( ( ) => render ( < Example value = { 1 } /> ) ) ;
85+
8386 expect ( state . editableValue ) . toEqual ( '1' ) ;
8487 expect ( state . externalValue ) . toEqual ( 1 ) ;
8588 expect ( state . parsedValue ) . toEqual ( 1 ) ;
@@ -102,7 +105,8 @@ describe('useEditableValue', () => {
102105
103106 // If there ARE pending changes,
104107 // an update to the external prop value should NOT override the local/pending value.
105- legacyRender ( < Example value = { 3 } /> , container ) ;
108+ act ( ( ) => render ( < Example value = { 3 } /> ) ) ;
109+
106110 expect ( state . editableValue ) . toEqual ( '2' ) ;
107111 expect ( state . externalValue ) . toEqual ( 3 ) ;
108112 expect ( state . parsedValue ) . toEqual ( 2 ) ;
@@ -120,8 +124,8 @@ describe('useEditableValue', () => {
120124 return null ;
121125 }
122126
123- const container = document . createElement ( 'div' ) ;
124- legacyRender ( < Example value = { 1 } /> , container ) ;
127+ act ( ( ) => render ( < Example value = { 1 } /> ) ) ;
128+
125129 expect ( state . editableValue ) . toEqual ( '1' ) ;
126130 expect ( state . externalValue ) . toEqual ( 1 ) ;
127131 expect ( state . parsedValue ) . toEqual ( 1 ) ;
@@ -153,8 +157,8 @@ describe('useEditableValue', () => {
153157 return null ;
154158 }
155159
156- const container = document . createElement ( 'div' ) ;
157- legacyRender ( < Example value = { 1 } /> , container ) ;
160+ act ( ( ) => render ( < Example value = { 1 } /> ) ) ;
161+
158162 expect ( state . editableValue ) . toEqual ( '1' ) ;
159163 expect ( state . externalValue ) . toEqual ( 1 ) ;
160164 expect ( state . parsedValue ) . toEqual ( 1 ) ;
0 commit comments