From 2b989fb7e6b6cc24b2d7e84d637d282403ffebc1 Mon Sep 17 00:00:00 2001 From: tharvik Date: Tue, 9 Jul 2024 13:58:30 +0200 Subject: [PATCH] chore: add test for nested v-model --- tests/setValue.spec.ts | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/setValue.spec.ts b/tests/setValue.spec.ts index 911a039b4..59048b0bf 100644 --- a/tests/setValue.spec.ts +++ b/tests/setValue.spec.ts @@ -295,17 +295,33 @@ describe('setValue', () => { template: '
{{ foo }} {{ bar }}
' }) + const NestedInputComponentChild = defineComponent({ + props: ['modelValue', 'onUpdate:modelValue'], + template: '
{{ modelValue }}
' + }) + const NestedInputComponent = defineComponent({ + props: ['modelValue', 'onUpdate:modelValue'], + template: '', + components: { NestedInputComponentChild } + }) + const Component = defineComponent({ - template: - '', + template: ` + + `, data() { return { plain: null, foo: null, - bar: null + bar: null, + nested: null } }, - components: { PlainInputComponent, MultiInputComponent } + components: { + PlainInputComponent, + MultiInputComponent, + NestedInputComponent + } }) describe('mount', () => { @@ -324,6 +340,14 @@ describe('setValue', () => { expect(multiInput.text()).toContain('fooValue') expect(multiInput.text()).toContain('barValue') }) + + it('triggers a normal `v-model` on nested Vue Components', async () => { + const wrapper = mount(Component) + const nested = wrapper.findComponent(NestedInputComponent) + const child = nested.findComponent(NestedInputComponentChild) + await child.setValue('nested-value') + expect(nested.text()).toContain('nested-value') + }) }) describe('shallowMount', () => { it('triggers a normal `v-model` on a Vue Component', async () => {