File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-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,20 @@ 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 , {
110
+ props : { msg : 'Hello world' } ,
111
+ attachTo : document . body
112
+ } )
113
+ expect (
114
+ document . body . firstChild ,
115
+ 'Container should have mounted component wrapper'
116
+ ) . toBeInstanceOf ( HTMLDivElement )
117
+
118
+ wrapper . unmount ( )
119
+ expect ( document . body . firstChild , 'Container should be empty' ) . toBeNull ( )
120
+ } )
105
121
} )
You can’t perform that action at this time.
0 commit comments