From 8b51a04053a19d643343a94a6eea0df816048862 Mon Sep 17 00:00:00 2001 From: Daniel Cook Date: Tue, 13 Aug 2019 09:05:58 +0100 Subject: [PATCH 1/3] 2.0.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 746f865d..161e25e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@testing-library/vue", - "version": "1.2.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5430639f..edde0e42 100644 --- a/package.json +++ b/package.json @@ -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": { From b430986fbade5d8bc7634d47cd7e679089024b35 Mon Sep 17 00:00:00 2001 From: Daniel Cook Date: Tue, 13 Aug 2019 09:52:42 +0100 Subject: [PATCH 2/3] Add functional rendering support and examples --- src/vue-testing-library.js | 8 ++++++- tests/__tests__/components/FunctionalSFC.vue | 3 +++ tests/__tests__/functional.js | 23 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/__tests__/components/FunctionalSFC.vue create mode 100644 tests/__tests__/functional.js diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js index 351babd4..a3267c46 100644 --- a/src/vue-testing-library.js +++ b/src/vue-testing-library.js @@ -81,13 +81,19 @@ function cleanup() { } function cleanupAtWrapper(wrapper) { + console.dir(wrapper) + if ( wrapper.element.parentNode && wrapper.element.parentNode.parentNode === document.body ) { document.body.removeChild(wrapper.element.parentNode) } - wrapper.destroy() + + if (wrapper.isVueInstance()) { + wrapper.destroy() + } + mountedWrappers.delete(wrapper) } diff --git a/tests/__tests__/components/FunctionalSFC.vue b/tests/__tests__/components/FunctionalSFC.vue new file mode 100644 index 00000000..b69d9c91 --- /dev/null +++ b/tests/__tests__/components/FunctionalSFC.vue @@ -0,0 +1,3 @@ + diff --git a/tests/__tests__/functional.js b/tests/__tests__/functional.js new file mode 100644 index 00000000..65c9e098 --- /dev/null +++ b/tests/__tests__/functional.js @@ -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!') +}) From 4977568d5d70ea479273d572a26b59b8db549a0d Mon Sep 17 00:00:00 2001 From: Daniel Cook Date: Tue, 13 Aug 2019 10:04:34 +0100 Subject: [PATCH 3/3] #41 removed debug logging --- src/vue-testing-library.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js index a3267c46..83aecc79 100644 --- a/src/vue-testing-library.js +++ b/src/vue-testing-library.js @@ -81,8 +81,6 @@ function cleanup() { } function cleanupAtWrapper(wrapper) { - console.dir(wrapper) - if ( wrapper.element.parentNode && wrapper.element.parentNode.parentNode === document.body