8000 :white_check_mark: add tests · vue-use-form/vue-use-form@d756de7 · GitHub
[go: up one dir, main page]

Skip to content

Commit d756de7

Browse files
committed
✅ add tests
1 parent ed5144b commit d756de7

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

test/core.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import { mount } from '@vue/test-utils'
2-
import { describe, expect, it, test } from 'vitest'
1+
// import { mount } from '@vue/test-utils'
2+
import { expect, test } from 'vitest'
33
import { useForm } from 'vue-use-form'
4-
import Login from './components/Login.vue'
4+
// import Login from './components/Login.vue'
55

6-
describe('useForm', () => {
7-
it('should be defined', () => {
8-
expect(useForm).to.toBeDefined()
9-
})
10-
11-
test('formState', () => {
12-
const wrapper = mount(Login)
13-
14-
expect(wrapper.get('input').text()).toMatchInlineSnapshot('""')
15-
})
6+
test('useForm', () => {
7+
expect(useForm).toBeDefined()
168
})

test/utils.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import setWith from 'lodash.setwith'
2+
import { expect, test } from 'vitest'
3+
import { getPath } from '../packages/core/src/utils/getPath'
4+
5+
test('getPath', () => {
6+
const obj = {}
7+
const key = 'user[0].name'
8+
setWith(obj, key, {
9+
inputValue: '',
10+
})
11+
12+
expect(obj).toMatchInlineSnapshot(`
13+
{
14+
"user": [
15+
{
16+
"name": {
17+
"inputValue": "",
18+
},
19+
},
20+
],
21+
}
22+
`)
23+
24+
expect(getPath(key, obj)).toMatchInlineSnapshot(`
25+
{
26+
"inputValue": "",
27+
}
28+
`)
29+
})

0 commit comments

Comments
 (0)
0