File tree Expand file tree Collapse file tree 2 files changed +38
-14
lines changed Expand file tree Collapse file tree 2 files changed +38
-14
lines changed Original file line number Diff line number Diff line change @@ -64,16 +64,4 @@ export const recordEvent = (
64
64
65
65
// Record the event message sent by the emit
66
66
events [ cid ] [ event ] . push ( args )
67
-
68
- if ( event . startsWith ( 'update:' ) ) {
69
- if ( args . length !== 1 ) {
70
- throw new Error (
71
- 'Two-way bound properties have to emit a single value. ' +
72
- args . length +
73
- ' values given.'
74
- )
75
- }
76
-
77
- vm . props [ event . slice ( 'update:' . length ) ] = args [ 0 ]
78
- }
79
67
}
Original file line number Diff line number Diff line change 1
1
import { mount } from '../src'
2
2
import WithProps from './components/WithProps.vue'
3
3
import Hello from './components/Hello.vue'
4
- import { defineComponent } from 'vue'
4
+ import { defineComponent , h } from 'vue'
5
5
6
6
describe ( 'props' , ( ) => {
7
7
it ( 'returns a single prop applied to a component' , ( ) => {
@@ -103,7 +103,9 @@ describe('props', () => {
103
103
104
104
const wrapper = mount ( component , {
105
105
props : {
106
- modelValue : 1
106
+ modelValue : 1 ,
107
+ 'onUpdate:modelValue' : async ( modelValue : number ) =>
108
+ wrapper . setProps ( { modelValue } )
107
109
}
108
110
} )
109
111
@@ -185,4 +187,38 @@ describe('props', () => {
185
187
foo : 'new value'
186
188
} )
187
189
} )
190
+
191
+ it ( 'https://github.com/vuejs/vue-test-utils-next/issues/440' , async ( ) => {
192
+ const Foo = defineComponent ( {
193
+ name : 'Foo' ,
194
+ props : {
195
+ foo : String
196
+ } ,
197
+ emits : [ 'update:foo' ] ,
198
+ setup ( props , ctx ) {
199
+ return ( ) =>
200
+ h (
201
+ 'div' ,
202
+ {
203
+ onClick : ( ) => {
204
+ ctx . emit ( 'update:foo' , 'world' )
205
+ }
206
+ } ,
207
+ props . foo
208
+ )
209
+ }
210
+ } )
211
+
212
+ const wrapper = mount ( Foo , {
213
+ props : {
214
+ foo : 'hello'
215
+ }
216
+ } )
217
+
218
+ expect ( wrapper . text ( ) ) . toEqual ( 'hello' )
219
+
220
+ await wrapper . trigger ( 'click' )
221
+
222
+ expect ( wrapper . text ( ) ) . toEqual ( 'hello' )
223
+ } )
188
224
} )
You can’t perform that action at this time.
0 commit comments