File tree Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Original file line number Diff line number Diff line change
1
+ import { defineComponent } from 'vue'
2
+
1
3
import { mount } from '../src'
2
4
3
5
const AXIOM = 'Rem is the best girl'
4
6
5
7
describe ( 'Unmount' , ( ) => {
6
8
it ( 'works on single root component' , ( ) => {
9
+ const errorHandler = jest . fn ( )
7
10
const Component = {
8
11
template : `
9
12
<div>${ AXIOM } </div>
10
- ` ,
11
- onErrorCaptured ( err : Error ) {
12
- throw err
13
- }
13
+ `
14
14
}
15
- const wrapper = mount ( Component )
16
- expect ( ( ) => wrapper . unmount ( ) ) . not . toThrowError ( )
15
+ const wrapper = mount ( Component , {
16
+ props : { } ,
17
+ global : {
18
+ config : {
19
+ errorHandler
20
+ }
21
+ }
22
+ } as any ) // The type checking keeps complaning about unmatched type which might be a bug
23
+ wrapper . unmount ( )
24
+ expect ( errorHandler ) . not . toHaveBeenCalled ( )
17
25
} )
18
26
19
27
it ( 'works on multi-root component' , ( ) => {
20
- const Component = {
28
+ const errorHandler = jest . fn ( )
29
+ const Component = defineComponent ( {
21
30
template : `
22
31
<div>${ AXIOM } </div>
23
32
<div>${ AXIOM } </div>
24
- ` ,
25
- onErrorCaptured ( err : Error ) {
26
- throw err
33
+ `
34
+ } )
35
+ const wrapper = mount ( Component , {
36
+ props : { } ,
37
+ global : {
38
+ config : {
39
+ errorHandler
40
+ }
27
41
}
28
- }
29
- const wrapper = mount ( Component )
42
+ } as any )
30
43
wrapper . unmount ( )
44
+ expect ( errorHandler ) . not . toHaveBeenCalled ( )
31
45
} )
32
46
} )
You can’t perform that action at this time.
0 commit comments