Skip to content

Commit 51ee70a

Browse files
committed
Investigate updating of v-model by changes to DOM input
1 parent 842baad commit 51ee70a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The `vue-testing-library` is a very light-weight solution for testing Vue
1717
components. It provides light utility functions on top of `@vue/test-utils`, in a way that encourages better testing practices.
1818
It's primary guiding principle is:
1919

20-
> [The more your tests resemble the way your software is used, the more confidence they can give you.][guiding-principle]
20+
The more your tests resemble the way your software is used, the more confidence they can give you.
2121

2222
## LICENSE
2323

src/Simulate.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@ export default {
22
click(elem) {
33
if (elem) {
44
if (elem.trigger) {
5-
elem.trigger('submit')
5+
return elem.trigger('submit')
66
}
77

88
if (elem.click) {
9-
elem.click()
9+
return elem.click()
1010
}
1111
}
1212
},
1313
submit(elem) {
1414
if (elem) {
1515
if (elem.trigger) {
16-
elem.trigger('submit')
16+
return elem.trigger('submit')
1717
}
1818

1919
if (elem.submit) {
20-
elem.submit()
20+
return elem.submit()
2121
}
2222
}
23+
},
24+
change (elem, value) {
25+
if (elem) {
26+
if (elem.trigger) {
27+
return elem.trigger('change', value)
28+
}
29+
30+
if (elem.value) {
31+
return elem.value = value
32+
}
33+
}
2334
}
2435
}

src/__tests__/form.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ test('login form submits', () => {
1414
const formNode = wrapper.find('form')
1515
const submitButtonNode = getByText('submit')
1616

17-
// Act
17+
// Act - this is waiting on an issue in @vue/test-utils to allow v-model to be updated by
18+
// changes to DOM elements
19+
20+
// Simulate.change(usernameNode, fakeUser.username)
21+
// Simulate.change(passwordNode, fakeUser.password)
1822
wrapper.setData(fakeUser)
1923

2024
// NOTE: in jsdom, it's not possible to trigger a form submission

0 commit comments

Comments
 (0)