File tree Expand file tree Collapse file tree 2 files changed +32
-14
lines changed Expand file tree Collapse file tree 2 files changed +32
-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,8 @@ 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 ) => wrapper . setProps ( { modelValue } )
107
108
}
108
109
} )
109
110
@@ -185,4 +186,33 @@ describe('props', () => {
185
186
foo : 'new value'
186
187
} )
187
188
} )
189
+
190
+ it ( 'https://github.com/vuejs/vue-test-utils-next/issues/440' , async ( ) => {
191
+ const Foo = defineComponent ( {
192
+ name : 'Foo' ,
193
+ props : {
194
+ foo : String ,
195
+ } ,
196
+ emits : [ 'update:foo' ] ,
197
+ setup ( props , ctx ) {
198
+ return ( ) => h ( 'div' , {
199
+ onClick : ( ) => {
200
+ ctx . emit ( 'update:foo' , 'world' )
201
+ } ,
202
+ } , props . foo )
203
+ }
204
+ } )
205
+
206
+ const wrapper = mount ( Foo , {
207
+ props : {
208
+ foo : 'hello'
209
+ }
210
+ } )
211
+
212
+ expect ( wrapper . text ( ) ) . toEqual ( 'hello' )
213
+
214
+ await wrapper . trigger ( 'click' )
215
+
216
+ expect ( wrapper . text ( ) ) . toEqual ( 'hello' )
217
+ } )
188
218
} )
You can’t perform that action at this time.
0 commit comments