@@ -105,6 +105,44 @@ describeWithShallowAndMount('setProps', (mountingMethod) => {
105
105
expect ( wrapper . text ( ) ) . to . equal ( 'There is no message yet' )
106
106
} )
107
107
108
+ it . only ( 'runs watchers correctly' , ( ) => {
109
+ const TestComponent = {
110
+ template : `<div id="app">
111
+ {{ stringified }}
112
+ </div>` ,
113
+ props : [ 'collection' ] ,
114
+ data : ( ) => ( {
115
+ data : ''
116
+ } ) ,
117
+ computed : {
118
+ stringified ( ) {
119
+ return this . collection . join ( ',' )
120
+ }
121
+ } ,
122
+ watch : {
123
+ collection : 'execute'
124
+ } ,
125
+ methods : {
126
+ execute ( ) {
127
+ this . data = this . stringified
128
+ }
129
+ }
130
+ }
131
+ const wrapper = mountingMethod ( TestComponent , {
132
+ propsData : { collection : [ ] }
133
+ } )
134
+ expect ( wrapper . vm . stringified ) . to . equal ( '' )
135
+ expect ( wrapper . vm . data ) . to . equal ( '' )
136
+
137
+ wrapper . setProps ( { collection : [ 1 , 2 , 3 ] } )
138
+ expect ( wrapper . vm . stringified ) . to . equal ( '1,2,3' )
139
+ expect ( wrapper . vm . data ) . to . equal ( '1,2,3' )
140
+
141
+ wrapper . vm . collection . push ( 4 , 5 )
142
+ expect ( wrapper . vm . stringified ) . to . equal ( '1,2,3,4,5' )
143
+ expect ( wrapper . vm . data ) . to . equal ( '1,2,3,4,5' )
144
+ } )
145
+
108
146
it ( 'throws an error if node is not a Vue instance' , ( ) => {
109
147
const message = 'wrapper.setProps() can only be called on a Vue instance'
110
148
const compiled = compileToFunctions ( '<div><p></p></div>' )
0 commit comments