File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,28 @@ describe('Coroutine', async () => {
2424 const success = await Renderer . create ( < p > { 13 } </ p > ) ;
2525 expect ( tree . toJSON ( ) ) . toEqual ( success . toJSON ( ) ) ;
2626 } ) ;
27+
28+ it ( 'should re-render the component if variables are updated' , async ( ) => {
29+ function getVariables ( ) {
30+ return { number : 0 } ;
31+ }
32+
33+ async function render ( { number, forceUpdate } ) {
34+ try {
35+ return < p > { number } </ p > ;
36+ } finally {
37+ await true ;
38+ if ( number === 0 ) forceUpdate ( { number : 1 } ) ;
39+ }
40+ }
41+
42+ const TestComponent = Coroutine . create ( render , getVariables ) ;
43+ const tree = await Renderer . create ( < TestComponent /> ) ;
44+
45+ const success = await Renderer . create ( < p > { 0 } </ p > ) ;
46+ expect ( tree . toJSON ( ) ) . toEqual ( success . toJSON ( ) ) ;
47+
48+ const updated = await Renderer . create ( < p > { 1 } </ p > ) ;
49+ expect ( tree . toJSON ( ) ) . toEqual ( updated . toJSON ( ) ) ;
50+ } ) ;
2751} ) ;
You can’t perform that action at this time.
0 commit comments