File tree Expand file tree Collapse file tree 2 files changed +5
-26
lines changed
Expand file tree Collapse file tree 2 files changed +5
-26
lines changed Original file line number Diff line number Diff line change @@ -89,31 +89,14 @@ test('unmounts', () => {
8989 expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
9090} )
9191
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 ?. ( ) )
9694
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' ) ) ,
11097 } )
11198
112- expect ( getByTestId ( 'node' ) ) . toBeInTheDocument ( )
113-
11499 unmount ( )
115100
116- expect ( queryByTestId ( 'node' ) ) . not . toBeInTheDocument ( )
117-
118101 expect ( ( ) => cleanup ( ) ) . not . toThrow ( )
119102} )
Original file line number Diff line number Diff line change @@ -60,11 +60,7 @@ function cleanup() {
6060}
6161
6262function 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 ) {
6864 document . body . removeChild ( wrapper . element . parentNode )
6965 }
7066
You can’t perform that action at this time.
0 commit comments