File tree Expand file tree Collapse file tree 3 files changed +33
-17
lines changed
test/unit/specs/mount/Wrapper Expand file tree Collapse file tree 3 files changed +33
-17
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ function update () {
1515 const vnodes = this . _render ( )
1616 this . _update ( vnodes )
1717 this . $children . forEach ( child => update . call ( child ) )
18+ this . _watchers . forEach ( watcher => {
19+ watcher . run ( )
20+ } )
1821}
1922
2023export default class VueWrapper extends Wrapper implements BaseWrapper {
Original file line number Diff line number Diff line change @@ -340,13 +340,6 @@ export default class Wrapper implements BaseWrapper {
340340 this . vm . $set ( this . vm , [ key ] , data [ key ] )
341341 } )
342342
343- Object . keys ( data ) . forEach ( ( key ) => {
344- // $FlowIgnore : Problem with possibly null this.vm
345- this . vm . _watchers . forEach ( ( watcher ) => {
346- if ( watcher . expression === key ) { watcher . run ( ) }
347- } )
348- } )
349-
350343 this . update ( )
351344 }
352345
@@ -393,10 +386,6 @@ export default class Wrapper implements BaseWrapper {
393386 }
394387 } )
395388 }
396- // $FlowIgnore
397- this . vm . _watchers . forEach ( ( watcher ) => {
398- if ( watcher . expression === key ) { watcher . run ( ) }
399- } )
400389 } )
401390 this . update ( )
402391 }
@@ -435,12 +424,6 @@ export default class Wrapper implements BaseWrapper {
435424 }
436425 } )
437426
438- Object . keys ( data ) . forEach ( ( key ) => {
439- // $FlowIgnore : Problem with possibly null this.vm
440- this . vm . _watchers . forEach ( ( watcher ) => {
441- if ( watcher . expression === key ) { watcher . run ( ) }
442- } )
443- } )
444427 this . update ( )
445428 // $FlowIgnore : Problem with possibly null this.vm
446429 this . vnode = this . vm . _vnode
Original file line number Diff line number Diff line change @@ -38,6 +38,36 @@ describe('update', () => {
3838 expect ( innerEl . hasClass ( 'is-on' ) ) . to . equal ( true )
3939 } )
4040
41+ it ( 'runs watchers' , ( ) => {
42+ const TestComponent = {
43+ template : `
44+ <div>
45+ <input v-model="text" />
46+ <button v-if="showButton">Submit</button>
47+ </div>
48+ ` ,
49+ data ( ) {
50+ return {
51+ text : '' ,
52+ showButton : false
53+ }
54+ } ,
55+
56+ watch : {
57+ text ( ) {
58+ this . showButton = true
59+ }
60+ }
61+ }
62+ const wrapper = mount ( TestComponent )
63+
64+ wrapper . find ( 'input' ) . element . value = 'Value'
65+ wrapper . find ( 'input' ) . trigger ( 'input' )
66+
67+ expect ( wrapper . vm . showButton ) . to . equal ( true )
68+ expect ( wrapper . find ( 'button' ) . exists ( ) ) . to . equal ( true )
69+ } )
70+
4171 it ( 'causes vm to re render, and retain slots' , ( ) => {
4272 const compiled = compileToFunctions ( '<div><slot></slot></div>' )
4373 const wrapper = mount ( compiled , { slots : { default : [ compileToFunctions ( '<div class="test-div" />' ) ] } } )
You can’t perform that action at this time.
0 commit comments