File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,9 @@ export function mount(
99
99
}
100
100
101
101
to . appendChild ( el )
102
+ app . onUnmount ( ( ) => {
103
+ to ?. removeChild ( el )
104
+ } )
102
105
}
103
106
const vm = app . mount ( el )
104
107
if ( errorsOnMount . length ) {
Original file line number Diff line number Diff line change @@ -102,4 +102,14 @@ describe('mount: general tests', () => {
102
102
} )
103
103
expect ( wrapper . text ( ) ) . toContain ( 'Hello world' )
104
104
} )
105
+
106
+ it ( 'should remove wrapper div when unmount' , ( ) => {
107
+ expect ( document . body . firstChild , 'Container should be empty' ) . toBeNull ( ) ;
108
+
109
+ const wrapper = mount ( Hello , { props : { msg : 'Hello world' } , attachTo : document . body } ) ;
110
+ expect ( document . body . firstChild , 'Container should have mounted component wrapper' ) . toBeInstanceOf ( HTMLDivElement ) ;
111
+
112
+ wrapper . unmount ( ) ;
113
+ expect ( document . body . firstChild , 'Container should be empty' ) . toBeNull ( ) ;
114
+ } )
105
115
} )
You can’t perform that action at this time.
0 commit comments