From 50e1a16f839907daf0776d1fb58a865eae4c1c35 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 10:28:57 +0100 Subject: [PATCH] test store --- admin/src/store/store.js | 4 ++-- admin/src/store/store.test.js | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/admin/src/store/store.js b/admin/src/store/store.js index 38a210fe1..d199368fb 100644 --- a/admin/src/store/store.js +++ b/admin/src/store/store.js @@ -6,10 +6,10 @@ Vue.use(Vuex) export const mutations = { openCreationsPlus: (state, i) => { - state.openCreations = state.openCreations + i + state.openCreations += i }, openCreationsMinus: (state, i) => { - state.openCreations = state.openCreations - i + state.openCreations -= i }, resetOpenCreations: (state) => { state.openCreations = 0 diff --git a/admin/src/store/store.test.js b/admin/src/store/store.test.js index 9ab9d980b..81d75f05f 100644 --- a/admin/src/store/store.test.js +++ b/admin/src/store/store.test.js @@ -1,6 +1,6 @@ import { mutations } from './store' -const { token } = mutations +const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations } = mutations describe('Vuex store', () => { describe('mutations', () => { @@ -11,5 +11,29 @@ describe('Vuex store', () => { 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) + }) + }) }) })