File tree 3 files changed +33
-17
lines changed
test/unit/specs/mount/Wrapper
3 files changed +33
-17
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ function update () {
15
15
const vnodes = this . _render ( )
16
16
this . _update ( vnodes )
17
17
this . $children . forEach ( child => update . call ( child ) )
18
+ this . _watchers . forEach ( watcher => {
19
+ watcher . run ( )
20
+ } )
18
21
}
19
22
20
23
export 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 {
340
340
this . vm . $set ( this . vm , [ key ] , data [ key ] )
341
341
} )
342
342
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
-
350
343
this . update ( )
351
344
}
352
345
@@ -393,10 +386,6 @@ export default class Wrapper implements BaseWrapper {
393
386
}
394
387
} )
395
388
}
396
- // $FlowIgnore
397
- this . vm . _watchers . forEach ( ( watcher ) => {
398
- if ( watcher . expression === key ) { watcher . run ( ) }
399
- } )
400
389
} )
401
390
this . update ( )
402
391
}
@@ -435,12 +424,6 @@ export default class Wrapper implements BaseWrapper {
435
424
}
436
425
} )
437
426
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
- } )
444
427
this . update ( )
445
428
// $FlowIgnore : Problem with possibly null this.vm
446
429
this . vnode = this . vm . _vnode
Original file line number Diff line number Diff line change @@ -38,6 +38,36 @@ describe('update', () => {
38
38
expect ( innerEl . hasClass ( 'is-on' ) ) . to . equal ( true )
39
39
} )
40
40
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
+
41
71
it ( 'causes vm to re render, and retain slots' , ( ) => {
42
72
const compiled = compileToFunctions ( '<div><slot></slot></div>' )
43
73
const wrapper = mount ( compiled , { slots : { default : [ compileToFunctions ( '<div class="test-div" />' ) ] } } )
You can’t perform that action at this time.
0 commit comments