File tree 2 files changed +5
-26
lines changed
2 files changed +5
-26
lines changed Original file line number Diff line number Diff line change @@ -89,31 +89,14 @@ test('unmounts', () => {
89
89
expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
90
90
} )
91
91
92
- test ( 'use unmount before cleanup' , ( ) => {
93
- const TestComponent = defineComponent ( ( _ , { slots} ) => {
94
- return ( ) => slots . default ?. ( )
95
- } )
92
+ test ( 'unmounts when no wrapper element is present' , ( ) => {
93
+ const Comp = defineComponent ( ( _ , ctx ) => ( ) => ctx . slots . default ?. ( ) )
96
94
97
- const { getByTestId, unmount, queryByTestId} = render ( {
98
- render ( ) {
99
- return h (
100
- TestComponent ,
101
- { } ,
102
- {
103
- default : ( ) =>
104
- h ( 'div' , {
105
- 'data-testid' : 'node' ,
106
- } ) ,
107
- } ,
108
- )
109
- } ,
95
+ const { unmount} = render ( {
96
+ render : ( ) => h ( Comp , ( ) => h ( 'div' ) ) ,
110
97
} )
111
98
112
- expect ( getByTestId ( 'node' ) ) . toBeInTheDocument ( )
113
-
114
99
unmount ( )
115
100
116
- expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
117
-
118
101
expect ( ( ) => cleanup ( ) ) . not . toThrow ( )
119
102
} )
Original file line number Diff line number Diff line change @@ -60,11 +60,7 @@ function cleanup() {
60
60
}
61
61
62
62
function cleanupAtWrapper ( wrapper ) {
63
- if (
64
- wrapper . element &&
65
- wrapper . element . parentNode &&
66
- wrapper . element . parentNode . parentNode === document . body
67
- ) {
63
+ if ( wrapper . element ?. parentNode ?. parentNode === document . body ) {
68
64
document . body . removeChild ( wrapper . element . parentNode )
69
65
}
70
66
You can’t perform that action at this time.
0 commit comments