Skip to content

Commit 910e3f4

Browse files
committed
tests: improve test
1 parent f804697 commit 910e3f4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/findComponent.spec.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Hello from './components/Hello.vue'
44
import ComponentWithoutName from './components/ComponentWithoutName.vue'
55

66
const compC = defineComponent({
7-
// name: 'ComponentC',
7+
name: 'ComponentC',
88
template: '<div class="C">C</div>'
99
})
1010

@@ -83,9 +83,21 @@ describe('findComponent', () => {
8383
expect(wrapper.findComponent({ name: 'component-c' }).exists()).toBeTruthy()
8484
})
8585

86-
it('finds root component', () => {
87-
const wrapper = mount(compA)
88-
expect(wrapper.findComponent(compA).exists()).toBe(true)
86+
it('finds root component', async () => {
87+
const Comp = defineComponent({
88+
name: 'C',
89+
template: `
90+
<input v-model="msg" />
91+
{{ msg }}
92+
`,
93+
data() {
94+
return { msg: 'foo' }
95+
}
96+
})
97+
const wrapper = mount(Comp)
98+
expect(wrapper.findComponent(Comp).exists()).toBe(true)
99+
await wrapper.find('input').setValue('bar')
100+
expect(wrapper.html()).toContain('bar')
89101
})
90102

91103
it('finds component without a name by using its object definition', () => {

0 commit comments

Comments
 (0)