File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ describe('ReactDOMRoot', () => {
133
133
expect ( container . textContent ) . toEqual ( '' ) ;
134
134
} ) ;
135
135
136
+ it ( 'can be immediately unmounted' , async ( ) => {
137
+ const root = ReactDOMClient . createRoot ( container ) ;
138
+ await act ( ( ) => {
139
+ root . unmount ( ) ;
140
+ } ) ;
141
+ } ) ;
142
+
136
143
it ( 'supports hydration' , async ( ) => {
137
144
const markup = await new Promise ( resolve =>
138
145
resolve (
@@ -392,6 +399,18 @@ describe('ReactDOMRoot', () => {
392
399
}
393
400
} ) ;
394
401
402
+ it ( 'throws if unmounting a root that has had its contents removed' , async ( ) => {
403
+ const root = ReactDOMClient . createRoot ( container ) ;
404
+ await act ( ( ) => {
405
+ root . render ( < div > Hi</ div > ) ;
406
+ } ) ;
407
+ container . innerHTML = '' ;
408
+
409
+ expect ( ( ) => {
410
+ root . unmount ( ) ;
411
+ } ) . toThrow ( 'The node to be removed is not a child of this node.' ) ;
412
+ } ) ;
413
+
395
414
it ( 'opts-in to concurrent default updates' , async ( ) => {
396
415
const root = ReactDOMClient . createRoot ( container , {
397
416
unstable_concurrentUpdatesByDefault : true ,
You can’t perform that action at this time.
0 commit comments