File tree 2 files changed +23
-0
lines changed
test/unit/specs/mount/Wrapper
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,8 @@ export default class Wrapper implements BaseWrapper {
413
413
}
414
414
// $FlowIgnore : Problem with possibly null this.vm
415
415
this . vm . _computedWatchers [ key ] . value = computed [ key ]
416
+ this . vm . _computedWatchers [ key ] . getter = ( ) => computed [ key ]
417
+
416
418
} else {
417
419
// $FlowIgnore : Problem with possibly null this.vm
418
420
if ( ! this . vm . _watchers . some ( w => w . getter . name === key ) ) {
@@ -422,6 +424,7 @@ export default class Wrapper implements BaseWrapper {
422
424
this . vm . _watchers . forEach ( ( watcher ) => {
423
425
if ( watcher . getter . name === key ) {
424
426
watcher . value = computed [ key ]
427
+ watcher . getter = ( ) => computed [ key ]
425
428
}
426
429
} )
427
430
}
Original file line number Diff line number Diff line change @@ -32,6 +32,26 @@ describe('setComputed', () => {
32
32
const computed1 = 'new computed'
33
33
wrapper . setComputed ( { computed1 } )
34
34
expect ( info . args [ 0 ] [ 0 ] ) . to . equal ( computed1 )
35
+ expect ( wrapper . vm . computed1 ) . to . equal ( computed1 )
36
+ } )
37
+
38
+ it ( 'updates vm computed value' , ( ) => {
39
+ const TestComponent = {
40
+ data ( ) {
41
+ return {
42
+ a : 1
43
+ }
44
+ } ,
45
+ computed : {
46
+ b ( ) {
47
+ return this . a * 2
48
+ }
49
+ }
50
+ }
51
+
52
+ const wrapper = mount ( TestComponent )
53
+ wrapper . setComputed ( { b : 3 } )
54
+ expect ( wrapper . vm . b ) . to . equal ( 3 )
35
55
} )
36
56
37
57
it ( 'throws an error if node is not a Vue instance' , ( ) => {
You can’t perform that action at this time.
0 commit comments