Skip to content

Commit

Permalink
Merge pull request #82 from testing-library/41-functional-rendering
Browse files Browse the repository at this point in the history
41 functional rendering
  • Loading branch information
dfcook committed Aug 13, 2019
2 parents f462051 + 4977568 commit 08500e4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@testing-library/vue",
"version": "1.2.0",
"version": "2.0.0",
"description": "Simple and complete Vue DOM testing utilities that encourage good testing practices.",
"main": "dist/vue-testing-library.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ function cleanupAtWrapper(wrapper) {
) {
document.body.removeChild(wrapper.element.parentNode)
}
wrapper.destroy()

if (wrapper.isVueInstance()) {
wrapper.destroy()
}

mountedWrappers.delete(wrapper)
}

Expand Down
3 changes: 3 additions & 0 deletions tests/__tests__/components/FunctionalSFC.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template functional>
<p>Hi!</p>
</template>
23 changes: 23 additions & 0 deletions tests/__tests__/functional.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { cleanup, render } from '@testing-library/vue'
import FunctionalSFC from './components/FunctionalSFC'

const Functional = {
functional: true,
render(createElement) {
return createElement('p', null, 'Hi!')
}
}

afterEach(cleanup)

it('renders functional comp', () => {
const { getByText } = render(Functional)

getByText('Hi!')
})

it('renders functional SFC comp', () => {
const { getByText } = render(FunctionalSFC)

getByText('Hi!')
})

0 comments on commit 08500e4

Please sign in to comment.