Skip to content

Commit

Permalink
chore: add test for nested v-model
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Jul 9, 2024
1 parent 89f8450 commit 74151cc
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/setValue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,30 @@ describe('setValue', () => {
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:

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

View workflow job for this annotation

GitHub Actions / build (18)

Delete `⏎·······`

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

View workflow job for this annotation

GitHub Actions / build (20)

Delete `⏎·······`
'<PlainInputComponent v-model="plain" /><MultiInputComponent v-model:foo="foo" v-model:bar="bar" />',
`<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 }

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

View workflow job for this annotation

GitHub Actions / build (18)

Replace `·PlainInputComponent,·MultiInputComponent,·NestedInputComponent` with `⏎········PlainInputComponent,⏎········MultiInputComponent,⏎········NestedInputComponent⏎·····`

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

View workflow job for this annotation

GitHub Actions / build (20)

Replace `·PlainInputComponent,·MultiInputComponent,·NestedInputComponent` with `⏎········PlainInputComponent,⏎········MultiInputComponent,⏎········NestedInputComponent⏎·····`
})

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

0 comments on commit 74151cc

Please sign in to comment.