rename commit in store to setUserSelectedInMassCreation

This commit is contained in:
ogerly 2022-02-01 09:48:22 +01:00
parent e3449fd2d1
commit 84509ef024
4 changed files with 44 additions and 11 deletions

View File

@ -56,7 +56,6 @@ const mocks = {
const propsData = {
type: '',
creation: [],
userSelectedInMassCreation: {},
}
describe('CreationFormular', () => {

View File

@ -29,6 +29,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
})
const toastErrorMock = jest.fn()
const storeCommitMock = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
@ -48,6 +49,12 @@ const mocks = {
}),
}
}),
$store: {
commit: storeCommitMock,
state: {
userSelectedInMassCreation: [],
},
},
}
describe('Creation', () => {
@ -113,7 +120,18 @@ describe('Creation', () => {
'push',
)
})
beforeEach(() => {
mocks.$store.state.setUserSelectedInMassCreation = [
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
]
})
it('removes the pushed item from itemsList', () => {
expect(wrapper.vm.itemsList).toEqual([
{
@ -128,7 +146,7 @@ describe('Creation', () => {
})
it('adds the pushed item to userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([
expect(storeCommitMock).toBeCalledWith('userSelectedInMassCreation', [
{
userId: 2,
firstName: 'Benjamin',
@ -138,6 +156,16 @@ describe('Creation', () => {
showDetails: false,
},
])
// expect(wrapper.vm.userSelectedInMassCreation).toEqual([
// {
// userId: 2,
// firstName: 'Benjamin',
// lastName: 'Blümchen',
// email: 'benjamin@bluemchen.de',
// creation: [800, 600, 400],
// showDetails: false,
// },
// ])
})
describe('remove', () => {
@ -157,7 +185,16 @@ describe('Creation', () => {
})
it('removes the item from userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
])
})
it('adds the item to itemsList', () => {
@ -222,7 +259,7 @@ describe('Creation', () => {
})
it('removes all items from userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
})
it('adds all items to itemsList', () => {

View File

@ -174,10 +174,10 @@ export default {
this.lala = letItemList
this.itemsMassCreationReverse = letItemList
this.itemsMassCreationReverse.reverse()
this.$store.commit('userSelectedInMassCreation', letItemList)
this.$store.commit('setUserSelectedInMassCreation', letItemList)
},
removeAllBookmark() {
this.$store.commit('userSelectedInMassCreation', [])
this.$store.commit('setUserSelectedInMassCreation', [])
this.getUsers()
},
},

View File

@ -24,15 +24,12 @@ export const mutations = {
moderator: (state, moderator) => {
state.moderator = moderator
},
userSelectedInMassCreation: (state, userSelectedInMassCreation) => {
setUserSelectedInMassCreation: (state, userSelectedInMassCreation) => {
state.userSelectedInMassCreation = userSelectedInMassCreation
},
}
export const actions = {
login: ({ dispatch, commit }, data) => {
commit('userSelectedInMassCreation', data)
},
logout: ({ commit, state }) => {
commit('token', null)
commit('moderator', null)