Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurewarth0920 committed Dec 9, 2022
1 parent 6a99b35 commit 9bd2918
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion 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'

Expand Down Expand Up @@ -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)
})
})

0 comments on commit 9bd2918

Please sign in to comment.