Skip to content

Commit 08500e4

Browse files
authored
Merge pull request #82 from testing-library/41-functional-rendering
41 functional rendering
2 parents f462051 + 4977568 commit 08500e4

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@testing-library/vue",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "Simple and complete Vue DOM testing utilities that encourage good testing practices.",
55
"main": "dist/vue-testing-library.js",
66
"scripts": {

src/vue-testing-library.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ function cleanupAtWrapper(wrapper) {
8787
) {
8888
document.body.removeChild(wrapper.element.parentNode)
8989
}
90-
wrapper.destroy()
90+
91+
if (wrapper.isVueInstance()) {
92+
wrapper.destroy()
93+
}
94+
9195
mountedWrappers.delete(wrapper)
9296
}
9397

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template functional>
2+
<p>Hi!</p>
3+
</template>

tests/__tests__/functional.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { cleanup, render } from '@testing-library/vue'
2+
import FunctionalSFC from './components/FunctionalSFC'
3+
4+
const Functional = {
5+
functional: true,
6+
render(createElement) {
7+
return createElement('p', null, 'Hi!')
8+
}
9+
}
10+
11+
afterEach(cleanup)
12+
13+
it('renders functional comp', () => {
14+
const { getByText } = render(Functional)
15+
16+
getByText('Hi!')
17+
})
18+
19+
it('renders functional SFC comp', () => {
20+
const { getByText } = render(FunctionalSFC)
21+
22+
getByText('Hi!')
23+
})

0 commit comments

Comments
 (0)