Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add test for nested v-model #2469

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions tests/setValue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,33 @@
template: '<div>{{ foo }} {{ bar }}</div>'
})

const NestedInputComponentChild = defineComponent({
props: ['modelValue', 'onUpdate:modelValue'],
template: '<div>{{ modelValue }}</div>'
})
const NestedInputComponent = defineComponent({
props: ['modelValue', 'onUpdate:modelValue'],
template: '<NestedInputComponentChild v-model="modelValue" />',
components: { NestedInputComponentChild }
})

const Component = defineComponent({
template:
'<PlainInputComponent v-model="plain" /><MultiInputComponent v-model:foo="foo" v-model:bar="bar" />',
template: `<PlainInputComponent v-model="plain" />
<MultiInputComponent v-model:foo="foo" v-model:bar="bar" />
<NestedInputComponent v-model="nested" />`,
data() {
return {
plain: null,
foo: null,
bar: null
bar: null,
nested: null
}
},
components: { PlainInputComponent, MultiInputComponent }
components: {
PlainInputComponent,
MultiInputComponent,
NestedInputComponent
}
})

describe('mount', () => {
Expand All @@ -324,6 +340,14 @@
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')

Check failure on line 349 in tests/setValue.spec.ts

View workflow job for this annotation

GitHub Actions / build (18)

tests/setValue.spec.ts > setValue > on component instance > mount > triggers a normal `v-model` on nested Vue Components

AssertionError: expected '' to contain 'nested-value' - Expected + Received - nested-value ❯ tests/setValue.spec.ts:349:31

Check failure on line 349 in tests/setValue.spec.ts

View workflow job for this annotation

GitHub Actions / build (20)

tests/setValue.spec.ts > setValue > on component instance > mount > triggers a normal `v-model` on nested Vue Components

AssertionError: expected '' to contain 'nested-value' - Expected + Received - nested-value ❯ tests/setValue.spec.ts:349:31
})
})
describe('shallowMount', () => {
it('triggers a normal `v-model` on a Vue Component', async () => {
Expand Down
Loading