diff --git a/test/unit/modules.spec.js b/test/unit/modules.spec.js index 9c6e96e46..7eae663dc 100644 --- a/test/unit/modules.spec.js +++ b/test/unit/modules.spec.js @@ -1,4 +1,4 @@ -import { h, nextTick } from 'vue' +import { computed, h, nextTick } from 'vue' import { mount } from 'test/helpers' import Vuex from '@/index' @@ -925,4 +925,31 @@ describe('Modules', () => { /getters should be function but "getters\.test" in module "foo\.bar" is true/ ) }) + + it('module: computed getter should be reactive after module registration', () => { + const store = new Vuex.Store({ + state: { + foo: 0 + }, + getters: { + getFoo: state => state.foo + }, + mutations: { + incrementFoo: state => state.foo++ + } + }) + + const computedFoo = computed(() => store.getters.getFoo) + store.commit('incrementFoo') + expect(computedFoo.value).toBe(1) + + store.registerModule('bar', { + state: { + bar: 0 + } + }) + + store.commit('incrementFoo') + expect(computedFoo.value).toBe(2) + }) })