test store

This commit is contained in:
Moriz Wahl 2021-11-24 10:28:57 +01:00
parent c98d615105
commit 50e1a16f83
2 changed files with 27 additions and 3 deletions

View File

@ -6,10 +6,10 @@ Vue.use(Vuex)
export const mutations = { export const mutations = {
openCreationsPlus: (state, i) => { openCreationsPlus: (state, i) => {
state.openCreations = state.openCreations + i state.openCreations += i
}, },
openCreationsMinus: (state, i) => { openCreationsMinus: (state, i) => {
state.openCreations = state.openCreations - i state.openCreations -= i
}, },
resetOpenCreations: (state) => { resetOpenCreations: (state) => {
state.openCreations = 0 state.openCreations = 0

View File

@ -1,6 +1,6 @@
import { mutations } from './store' import { mutations } from './store'
const { token } = mutations const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations } = mutations
describe('Vuex store', () => { describe('Vuex store', () => {
describe('mutations', () => { describe('mutations', () => {
@ -11,5 +11,29 @@ describe('Vuex store', () => {
expect(state.token).toEqual('1234') expect(state.token).toEqual('1234')
}) })
}) })
describe('openCreationsPlus', () => {
it('increases the open creations by a given number', () => {
const state = { openCreations: 0 }
openCreationsPlus(state, 12)
expect(state.openCreations).toEqual(12)
})
})
describe('openCreationsMinus', () => {
it('decreases the open creations by a given number', () => {
const state = { openCreations: 12 }
openCreationsMinus(state, 2)
expect(state.openCreations).toEqual(10)
})
})
describe('resetOpenCreations', () => {
it('sets the open creations to 0', () => {
const state = { openCreations: 24 }
resetOpenCreations(state)
expect(state.openCreations).toEqual(0)
})
})
}) })
}) })