Skip to content

Commit f7f62ee

Browse files
committed
feat: add test for input
1 parent c057389 commit f7f62ee

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/TheInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
const inputValue = defineModel('inputValue', {
2+
const inputValue = defineModel('modelValue', {
33
type: String,
44
default: '',
55
})

tests/the-input.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { mount } from '@vue/test-utils'
2+
import { describe, expect, it } from 'vitest'
3+
import TheInput from '../src/components/TheInput.vue'
4+
5+
describe('test for TheInput.vue', () => {
6+
it('create and set value', async () => {
7+
const wrapper = mount(TheInput, {
8+
props: {
9+
modelValue: 'text',
10+
},
11+
})
12+
const element = wrapper.element as HTMLInputElement
13+
expect(element).toBeTruthy()
14+
expect(element.value).toBe('text')
15+
await wrapper.setProps({ modelValue: 'new text' })
16+
expect(wrapper.find('input').element.value).toBe('new text')
17+
})
18+
})

0 commit comments

Comments
 (0)