File tree Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -216,10 +216,7 @@ export class VueWrapper<T extends ComponentPublicInstance> {
216
216
)
217
217
}
218
218
219
- if ( this . parentElement ) {
220
- this . parentElement . removeChild ( this . element )
221
- }
222
- this . __app . unmount ( this . element )
219
+ this . __app . unmount ( this . parentElement )
223
220
}
224
221
}
225
222
Original file line number Diff line number Diff line change
1
+ import { defineComponent } from 'vue'
2
+
3
+ import { mount } from '../src'
4
+
5
+ describe ( 'Unmount' , ( ) => {
6
+ it ( 'works on single root component' , ( ) => {
7
+ const errorHandler = jest . fn ( )
8
+ const Component = {
9
+ template : `
10
+ <div></div>
11
+ `
12
+ }
13
+ const wrapper = mount ( Component , {
14
+ props : { } ,
15
+ global : {
16
+ config : {
17
+ errorHandler
18
+ }
19
+ }
20
+ } as any ) // The type checking keeps complaning about unmatched type which might be a bug
21
+ wrapper . unmount ( )
22
+ expect ( errorHandler ) . not . toHaveBeenCalled ( )
23
+ } )
24
+
25
+ it ( 'works on multi-root component' , ( ) => {
26
+ const errorHandler = jest . fn ( )
27
+ const Component = defineComponent ( {
28
+ template : `
29
+ <div></div>
30
+ <div></div>
31
+ `
32
+ } )
33
+ const wrapper = mount ( Component , {
34
+ props : { } ,
35
+ global : {
36
+ config : {
37
+ errorHandler
38
+ }
39
+ }
40
+ } as any )
41
+ wrapper . unmount ( )
42
+ expect ( errorHandler ) . not . toHaveBeenCalled ( )
43
+ } )
44
+ } )
You can’t perform that action at this time.
0 commit comments