@@ -112,6 +112,7 @@ describe('api: options', () => {
112
112
const spyA = jest . fn ( returnThis )
113
113
const spyB = jest . fn ( returnThis )
114
114
const spyC = jest . fn ( returnThis )
115
+ const spyD = jest . fn ( returnThis )
115
116
116
117
let ctx : any
117
118
const Comp = {
@@ -121,7 +122,8 @@ describe('api: options', () => {
121
122
bar : 2 ,
122
123
baz : {
123
124
qux : 3
124
- }
125
+ } ,
126
+ qux : 4
125
127
}
126
128
} ,
127
129
watch : {
@@ -132,10 +134,14 @@ describe('api: options', () => {
132
134
baz : {
133
135
handler : spyC ,
134
136
deep : true
137
+ } ,
138
+ qux : {
139
+ handler : 'onQuxChange'
135
140
}
136
141
} ,
137
142
methods : {
138
- onFooChange : spyA
143
+ onFooChange : spyA ,
144
+ onQuxChange : spyD
139
145
} ,
140
146
render ( ) {
141
147
ctx = this
@@ -164,6 +170,11 @@ describe('api: options', () => {
164
170
expect ( spyC ) . toHaveBeenCalledTimes ( 1 )
165
171
// new and old objects have same identity
166
172
assertCall ( spyC , 0 , [ { qux : 4 } , { qux : 4 } ] )
173
+
174
+ ctx . qux ++
175
+ await nextTick ( )
176
+ expect ( spyD ) . toHaveBeenCalledTimes ( 1 )
177
+ assertCall ( spyD , 0 , [ 5 , 4 ] )
167
178
} )
168
179
169
180
test ( 'watch array' , async ( ) => {
@@ -707,7 +718,10 @@ describe('api: options', () => {
707
718
test ( 'Expected a function as watch handler' , ( ) => {
708
719
const Comp = {
709
720
watch : {
710
- foo : 'notExistingMethod'
721
+ foo : 'notExistingMethod' ,
722
+ foo2 : {
723
+ handler : 'notExistingMethod2'
724
+ }
711
725
} ,
712
726
render ( ) { }
713
727
}
@@ -718,6 +732,9 @@ describe('api: options', () => {
718
732
expect (
719
733
'Invalid watch handler specified by key "notExistingMethod"'
720
734
) . toHaveBeenWarned ( )
735
+ expect (
736
+ 'Invalid watch handler specified by key "notExistingMethod2"'
737
+ ) . toHaveBeenWarned ( )
721
738
} )
722
739
723
740
test ( 'Invalid watch option' , ( ) => {
0 commit comments