File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 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'
23import '@testing-library/jest-dom'
34
45test ( 'baseElement defaults to document.body' , ( ) => {
@@ -87,3 +88,15 @@ test('unmounts', () => {
8788
8889 expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
8990} )
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() {
6060}
6161
6262function cleanupAtWrapper ( wrapper ) {
63- if (
64- wrapper . element . parentNode &&
65- wrapper . element . parentNode . parentNode === document . body
66- ) {
63+ if ( wrapper . element ?. parentNode ?. parentNode === document . body ) {
6764 document . body . removeChild ( wrapper . element . parentNode )
6865 }
6966
You can’t perform that action at this time.
0 commit comments