From caabd06490c84011845328f7bf38224c3f38cfeb Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Mon, 7 Feb 2022 17:06:11 +1000 Subject: [PATCH 1/3] chore: add repro --- tests/components/LastUpdated.vue | 12 ++++++++++++ tests/unmount.spec.ts | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/components/LastUpdated.vue diff --git a/tests/components/LastUpdated.vue b/tests/components/LastUpdated.vue new file mode 100644 index 000000000..20d23ac00 --- /dev/null +++ b/tests/components/LastUpdated.vue @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/tests/unmount.spec.ts b/tests/unmount.spec.ts index f9f824763..c4e8083ba 100644 --- a/tests/unmount.spec.ts +++ b/tests/unmount.spec.ts @@ -1,4 +1,5 @@ import { defineComponent } from 'vue' +import LastUpdated from './components/LastUpdated.vue' import { mount } from '../src' @@ -41,4 +42,20 @@ describe('Unmount', () => { wrapper.unmount() expect(errorHandler).not.toHaveBeenCalled() }) + + it("The LastUpdated component renders the 'when' property", async () => { + const wrapper = mount(LastUpdated, { props: { when: 'today' } }) + + await wrapper.vm.$nextTick() + expect(wrapper.html()).toContain('today') + wrapper.unmount() + }) + + it("The LastUpdated component doesn't render when 'when' is undefined", async () => { + const wrapper = mount(LastUpdated, { props: { when: undefined } }) + + await wrapper.vm.$nextTick() + expect(wrapper.html()).not.toContain('today') + wrapper.unmount() + }) }) From 487ef948cd9c14bf3056a6e06cb76be03f934454 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Mon, 7 Feb 2022 17:07:36 +1000 Subject: [PATCH 2/3] lint --- tests/components/LastUpdated.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/components/LastUpdated.vue b/tests/components/LastUpdated.vue index 20d23ac00..7612847db 100644 --- a/tests/components/LastUpdated.vue +++ b/tests/components/LastUpdated.vue @@ -6,7 +6,7 @@ \ No newline at end of file + From 03c271a7141adaf8ac3461209410e2ae6b53de2d Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Mon, 7 Feb 2022 17:14:39 +1000 Subject: [PATCH 3/3] add more regressions --- src/components/ParentComponent.vue | 7 +++++++ tests/components/ParentComponent.vue | 7 +++++++ tests/features/suspense.spec.ts | 17 +++++++++++++++++ tests/find.spec.ts | 10 ++++++++++ 4 files changed, 41 insertions(+) create mode 100644 src/components/ParentComponent.vue create mode 100644 tests/components/ParentComponent.vue diff --git a/src/components/ParentComponent.vue b/src/components/ParentComponent.vue new file mode 100644 index 000000000..950192c9f --- /dev/null +++ b/src/components/ParentComponent.vue @@ -0,0 +1,7 @@ + diff --git a/tests/components/ParentComponent.vue b/tests/components/ParentComponent.vue new file mode 100644 index 000000000..950192c9f --- /dev/null +++ b/tests/components/ParentComponent.vue @@ -0,0 +1,7 @@ + diff --git a/tests/features/suspense.spec.ts b/tests/features/suspense.spec.ts index 5b4c8cd67..4eb553fb9 100644 --- a/tests/features/suspense.spec.ts +++ b/tests/features/suspense.spec.ts @@ -1,5 +1,6 @@ import SuspenseComponent from '../components/Suspense.vue' import { mount, flushPromises } from '../../src' +import { defineComponent } from '@vue/compat' let mockShouldError = false jest.mock('../utils', () => ({ @@ -32,4 +33,20 @@ describe('suspense', () => { expect(wrapper.html()).toContain('Error!') }) + + test('returns the element if it is a root element inside Suspense', () => { + const Async = defineComponent({ + // works if there is a root element + // template: '

Hello

There
' + // otherwise does not find the element + template: '

Hello

There' + }) + const Component = defineComponent({ + components: { Async }, + template: '' + }) + + const wrapper = mount(Component) + expect(wrapper.get('#my-span')).not.toBeNull() + }) }) diff --git a/tests/find.spec.ts b/tests/find.spec.ts index a296ab438..2ef277216 100644 --- a/tests/find.spec.ts +++ b/tests/find.spec.ts @@ -2,6 +2,7 @@ import { defineComponent, h, nextTick, Fragment } from 'vue' import { mount, VueWrapper } from '../src' import SuspenseComponent from './components/Suspense.vue' +import ParentComponent from './compodefineComponentponent.vue' describe('find', () => { it('find using single root node', () => { @@ -336,4 +337,13 @@ describe('findAll', () => { ).toBe(true) }) }) + + // https://github.com/vuejs/test-utils/issues/1233 + it('finds 3 children', () => { + const wrapper = mount(ParentComponent) + + const parent = wrapper.get('.parent') + + expect(parent.findAll('div').length).toBe(3) + }) })