Commit 3ecde9e 1 parent f5a3483 commit 3ecde9e Copy full SHA for 3ecde9e
File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
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,15 @@ test('unmounts', () => {
87
88
88
89
expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
89
90
} )
91
+
92
+ test ( 'unmounts when no wrapper element is present' , ( ) => {
93
+ const Comp = defineComponent ( ( _ , ctx ) => ( ) => ctx . slots . default ?. ( ) )
94
+
95
+ const { unmount} = render ( {
96
+ render : ( ) => h ( Comp , ( ) => h ( 'div' ) ) ,
97
+ } )
98
+
99
+ unmount ( )
100
+
101
+ expect ( ( ) => cleanup ( ) ) . not . toThrow ( )
102
+ } )
Original file line number Diff line number Diff line change @@ -60,10 +60,7 @@ function cleanup() {
60
60
}
61
61
62
62
function cleanupAtWrapper ( wrapper ) {
63
- if (
64
- wrapper . element . parentNode &&
65
- wrapper . element . parentNode . parentNode === document . body
66
- ) {
63
+ if ( wrapper . element ?. parentNode ?. parentNode === document . body ) {
67
64
document . body . removeChild ( wrapper . element . parentNode )
68
65
}
69
66
You can’t perform that action at this time.
0 commit comments