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 = (
6464
6565 // Record the event message sent by the emit
6666 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- }
7967}
Original file line number Diff line number Diff line change 11import { mount } from '../src'
22import WithProps from './components/WithProps.vue'
33import Hello from './components/Hello.vue'
4- import { defineComponent } from 'vue'
4+ import { defineComponent , h } from 'vue'
55
66describe ( 'props' , ( ) => {
77 it ( 'returns a single prop applied to a component' , ( ) => {
@@ -103,7 +103,9 @@ describe('props', () => {
103103
104104 const wrapper = mount ( component , {
105105 props : {
106- modelValue : 1
106+ modelValue : 1 ,
107+ 'onUpdate:modelValue' : async ( modelValue : number ) =>
108+ wrapper . setProps ( { modelValue } )
107109 }
108110 } )
109111
@@ -185,4 +187,38 @@ describe('props', () => {
185187 foo : 'new value'
186188 } )
187189 } )
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+ } )
188224} )
You can’t perform that action at this time.
0 commit comments