File tree 1 file changed +28
-1
lines changed
1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
- import { h , nextTick } from 'vue'
1
+ import { computed , h , nextTick } from 'vue'
2
2
import { mount } from 'test/helpers'
3
3
import Vuex from '@/index'
4
4
@@ -925,4 +925,31 @@ describe('Modules', () => {
925
925
/ g e t t e r s s h o u l d b e f u n c t i o n b u t " g e t t e r s \. t e s t " i n m o d u l e " f o o \. b a r " i s t r u e /
926
926
)
927
927
} )
928
+
929
+ it ( 'module: computed getter should be reactive after module registration' , ( ) => {
930
+ const store = new Vuex . Store ( {
931
+ state : {
932
+ foo : 0
933
+ } ,
934
+ getters : {
935
+ getFoo : state => state . foo ,
936
+ } ,
937
+ mutations : {
938
+ incrementFoo : state => state . foo ++
939
+ }
940
+ } )
941
+
942
+ const computedFoo = computed ( ( ) => store . getters . getFoo )
943
+ store . commit ( 'incrementFoo' )
944
+ expect ( computedFoo . value ) . toBe ( 1 )
945
+
946
+ store . registerModule ( 'bar' , {
947
+ state : {
948
+ bar : 0
949
+ }
950
+ } )
951
+
952
+ store . commit ( 'incrementFoo' )
953
+ expect ( computedFoo . value ) . toBe ( 2 )
954
+ } )
928
955
} )
You can’t perform that action at this time.
0 commit comments