Skip to content

Commit 11042b8

Browse files
committed
ci: add test case to fix testing-library#311
1 parent 1088c72 commit 11042b8

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/__tests__/render.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {render} from '..'
1+
import {render, cleanup} from '..'
2+
import {h, defineComponent} from 'vue'
23
import '@testing-library/jest-dom'
34

45
test('baseElement defaults to document.body', () => {
@@ -87,3 +88,34 @@ test('unmounts', () => {
8788

8889
expect(queryByTestId('node')).not.toBeInTheDocument()
8990
})
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+
})

0 commit comments

Comments
 (0)