Skip to content

Commit 9bd2918

Browse files
test: add test case
1 parent 6a99b35 commit 9bd2918

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

test/unit/modules.spec.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, nextTick } from 'vue'
1+
import { computed, h, nextTick } from 'vue'
22
import { mount } from 'test/helpers'
33
import Vuex from '@/index'
44

@@ -925,4 +925,31 @@ describe('Modules', () => {
925925
/getters should be function but "getters\.test" in module "foo\.bar" is true/
926926
)
927927
})
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+
})
928955
})

0 commit comments

Comments
 (0)