Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix getters being destroyed on component destroy (#1878) #1883

Merged
merged 5 commits into from
Oct 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add spy
  • Loading branch information
kiaking committed Aug 19, 2021
commit c7930f4192fdbccac945ded90cf7168508d1a800
9 changes: 8 additions & 1 deletion test/unit/modules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,16 @@ describe('Modules', () => {
it('should keep getters when component gets destroyed', async () => {
const store = new Vuex.Store()

const spy = jest.fn()

const moduleA = {
namespaced: true,
state: () => ({ value: 1 }),
getters: {
getState: (state) => state.value
getState (state) {
spy()
return state.value
}
},
mutations: {
increment: (state) => { state.value++ }
Expand All @@ -160,13 +165,15 @@ describe('Modules', () => {
})

expect(store.getters['moduleA/getState']).toBe(1)
expect(spy).toHaveBeenCalledTimes(1)

vm.show = 'b'
await nextTick()

store.commit('moduleA/increment')

expect(store.getters['moduleA/getState']).toBe(2)
posva marked this conversation as resolved.
Show resolved Hide resolved
expect(spy).toHaveBeenCalledTimes(2)
})
})

Expand Down