File tree 1 file changed +33
-1
lines changed
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
- import { render } from '..'
1
+ import { render , cleanup } from '..'
2
+ import { h , defineComponent } from 'vue'
2
3
import '@testing-library/jest-dom'
3
4
4
5
test ( 'baseElement defaults to document.body' , ( ) => {
@@ -87,3 +88,34 @@ test('unmounts', () => {
87
88
88
89
expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
89
90
} )
91
+
92
+ test ( 'use unmount before cleanup' , ( ) => {
93
+ const ChildComponent = defineComponent ( ( ) => {
94
+ return ( ) =>
95
+ h (
96
+ 'div' ,
97
+ {
98
+ 'data-testid' : 'node' ,
99
+ } ,
100
+ [ 'Hi' ] ,
101
+ )
102
+ } )
103
+
104
+ const ParentComponent = defineComponent ( ( _ , { slots} ) => {
105
+ return ( ) => slots . default ?. ( )
106
+ } )
107
+
108
+ const { getByTestId, unmount, queryByTestId} = render ( {
109
+ render ( ) {
110
+ return h ( ParentComponent , { } , { default : ( ) => h ( ChildComponent ) } )
111
+ } ,
112
+ } )
113
+
114
+ expect ( getByTestId ( 'node' ) ) . toBeInTheDocument ( )
115
+
116
+ unmount ( )
117
+
118
+ expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
119
+
120
+ expect ( ( ) => cleanup ( ) ) . not . toThrow ( )
121
+ } )
You can’t perform that action at this time.
0 commit comments