Merge branch 'master' into 2051-list-all-confirmed-contribution

This commit is contained in:
elweyn 2022-07-15 13:46:46 +02:00
commit ed75dce369
4 changed files with 31 additions and 2 deletions

View File

@ -59,6 +59,7 @@ export class ContributionResolver {
order: {
createdAt: order,
},
withDeleted: true,
skip: (currentPage - 1) * pageSize,
take: pageSize,
})

View File

@ -13,6 +13,7 @@ export const login = gql`
hasElopage
publisherId
isAdmin
creation
}
}
`
@ -30,6 +31,7 @@ export const verifyLogin = gql`
hasElopage
publisherId
isAdmin
creation
}
}
`

View File

@ -47,6 +47,9 @@ export const mutations = {
hasElopage: (state, hasElopage) => {
state.hasElopage = hasElopage
},
creation: (state, creation) => {
state.creation = creation
},
}
export const actions = {
@ -60,6 +63,7 @@ export const actions = {
commit('hasElopage', data.hasElopage)
commit('publisherId', data.publisherId)
commit('isAdmin', data.isAdmin)
commit('creation', data.creation)
},
logout: ({ commit, state }) => {
commit('token', null)
@ -71,6 +75,7 @@ export const actions = {
commit('hasElopage', false)
commit('publisherId', null)
commit('isAdmin', false)
commit('creation', null)
localStorage.clear()
},
}
@ -96,6 +101,7 @@ try {
newsletterState: null,
hasElopage: false,
publisherId: null,
creation: null,
},
getters: {},
// Syncronous mutation of the state

View File

@ -30,6 +30,7 @@ const {
publisherId,
isAdmin,
hasElopage,
creation,
} = mutations
const { login, logout } = actions
@ -139,6 +140,14 @@ describe('Vuex store', () => {
expect(state.hasElopage).toBeTruthy()
})
})
describe('creation', () => {
it('sets the state of creation', () => {
const state = { creation: null }
creation(state, true)
expect(state.creation).toEqual(true)
})
})
})
describe('actions', () => {
@ -156,11 +165,12 @@ describe('Vuex store', () => {
hasElopage: false,
publisherId: 1234,
isAdmin: true,
creation: ['1000', '1000', '1000'],
}
it('calls nine commits', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenCalledTimes(8)
expect(commit).toHaveBeenCalledTimes(9)
})
it('commits email', () => {
@ -202,6 +212,11 @@ describe('Vuex store', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', true)
})
it('commits creation', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(9, 'creation', ['1000', '1000', '1000'])
})
})
describe('logout', () => {
@ -210,7 +225,7 @@ describe('Vuex store', () => {
it('calls nine commits', () => {
logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(8)
expect(commit).toHaveBeenCalledTimes(9)
})
it('commits token', () => {
@ -253,6 +268,11 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', false)
})
it('commits creation', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(9, 'creation', null)
})
// how to get this working?
it.skip('calls localStorage.clear()', () => {
const clearStorageMock = jest.fn()