File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
packages/runtime-core/__tests__ Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -141,21 +141,32 @@ describe('renderer: component', () => {
141
141
} )
142
142
143
143
// #2170
144
- test ( 'should have access to instance’s “ $el” property in watcher when rendereing with watched prop ' , async ( ) => {
144
+ test ( 'instance. $el should be exposed to watch options ' , async ( ) => {
145
145
function returnThis ( this : any ) {
146
146
return this
147
147
}
148
148
const propWatchSpy = jest . fn ( returnThis )
149
+ const dataWatchSpy = jest . fn ( returnThis )
149
150
let instance : any
150
151
const Comp = {
151
152
props : {
152
153
testProp : String
153
154
} ,
154
155
156
+ data ( ) {
157
+ return {
158
+ testData : undefined
159
+ }
160
+ } ,
161
+
155
162
watch : {
156
163
testProp ( ) {
157
164
// @ts -ignore
158
165
propWatchSpy ( this . $el )
166
+ } ,
167
+ testData ( ) {
168
+ // @ts -ignore
169
+ dataWatchSpy ( this . $el )
159
170
}
160
171
} ,
161
172
@@ -172,10 +183,15 @@ describe('renderer: component', () => {
172
183
render ( h ( Comp ) , root )
173
184
await nextTick ( )
174
185
expect ( propWatchSpy ) . not . toHaveBeenCalled ( )
186
+ expect ( dataWatchSpy ) . not . toHaveBeenCalled ( )
175
187
176
188
render ( h ( Comp , { testProp : 'prop ' } ) , root )
177
189
await nextTick ( )
178
190
expect ( propWatchSpy ) . toHaveBeenCalledWith ( instance . $el )
191
+
192
+ instance . testData = 1
193
+ await nextTick ( )
194
+ expect ( dataWatchSpy ) . toHaveBeenCalledWith ( instance . $el )
179
195
} )
180
196
181
197
// #2200
You can’t perform that action at this time.
0 commit comments