mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-20 20:01:31 +00:00
fix frontend tests
This commit is contained in:
parent
148bd6286c
commit
3f0aa00dc3
@ -18,10 +18,8 @@ const {
|
||||
language,
|
||||
email,
|
||||
token,
|
||||
username,
|
||||
firstName,
|
||||
lastName,
|
||||
description,
|
||||
coinanimation,
|
||||
newsletterState,
|
||||
publisherId,
|
||||
@ -65,14 +63,6 @@ describe('Vuex store', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('username', () => {
|
||||
it('sets the state of username', () => {
|
||||
const state = { username: null }
|
||||
username(state, 'user')
|
||||
expect(state.username).toEqual('user')
|
||||
})
|
||||
})
|
||||
|
||||
describe('firstName', () => {
|
||||
it('sets the state of firstName', () => {
|
||||
const state = { firstName: null }
|
||||
@ -89,14 +79,6 @@ describe('Vuex store', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('description', () => {
|
||||
it('sets the state of description', () => {
|
||||
const state = { description: null }
|
||||
description(state, 'Nickelbrille')
|
||||
expect(state.description).toEqual('Nickelbrille')
|
||||
})
|
||||
})
|
||||
|
||||
describe('coinanimation', () => {
|
||||
it('sets the state of coinanimation', () => {
|
||||
const state = { coinanimation: true }
|
||||
@ -169,10 +151,8 @@ describe('Vuex store', () => {
|
||||
const commitedData = {
|
||||
email: 'user@example.org',
|
||||
language: 'de',
|
||||
username: 'peter',
|
||||
firstName: 'Peter',
|
||||
lastName: 'Lustig',
|
||||
description: 'Nickelbrille',
|
||||
coinanimation: false,
|
||||
klickTipp: {
|
||||
newsletterState: true,
|
||||
@ -182,9 +162,9 @@ describe('Vuex store', () => {
|
||||
isAdmin: true,
|
||||
}
|
||||
|
||||
it('calls eleven commits', () => {
|
||||
it('calls nine commits', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenCalledTimes(11)
|
||||
expect(commit).toHaveBeenCalledTimes(9)
|
||||
})
|
||||
|
||||
it('commits email', () => {
|
||||
@ -197,49 +177,39 @@ describe('Vuex store', () => {
|
||||
expect(commit).toHaveBeenNthCalledWith(2, 'language', 'de')
|
||||
})
|
||||
|
||||
it('commits username', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(3, 'username', 'peter')
|
||||
})
|
||||
|
||||
it('commits firstName', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(4, 'firstName', 'Peter')
|
||||
expect(commit).toHaveBeenNthCalledWith(3, 'firstName', 'Peter')
|
||||
})
|
||||
|
||||
it('commits lastName', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(5, 'lastName', 'Lustig')
|
||||
})
|
||||
|
||||
it('commits description', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(6, 'description', 'Nickelbrille')
|
||||
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', 'Lustig')
|
||||
})
|
||||
|
||||
it('commits coinanimation', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(7, 'coinanimation', false)
|
||||
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', false)
|
||||
})
|
||||
|
||||
it('commits newsletterState', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', true)
|
||||
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', true)
|
||||
})
|
||||
|
||||
it('commits hasElopage', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'hasElopage', false)
|
||||
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false)
|
||||
})
|
||||
|
||||
it('commits publisherId', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', 1234)
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', 1234)
|
||||
})
|
||||
|
||||
it('commits isAdmin', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', true)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', true)
|
||||
})
|
||||
})
|
||||
|
||||
@ -247,9 +217,9 @@ describe('Vuex store', () => {
|
||||
const commit = jest.fn()
|
||||
const state = {}
|
||||
|
||||
it('calls eleven commits', () => {
|
||||
it('calls nine commits', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenCalledTimes(11)
|
||||
expect(commit).toHaveBeenCalledTimes(9)
|
||||
})
|
||||
|
||||
it('commits token', () => {
|
||||
@ -262,49 +232,39 @@ describe('Vuex store', () => {
|
||||
expect(commit).toHaveBeenNthCalledWith(2, 'email', null)
|
||||
})
|
||||
|
||||
it('commits username', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(3, 'username', '')
|
||||
})
|
||||
|
||||
it('commits firstName', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(4, 'firstName', '')
|
||||
expect(commit).toHaveBeenNthCalledWith(3, 'firstName', '')
|
||||
})
|
||||
|
||||
it('commits lastName', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(5, 'lastName', '')
|
||||
})
|
||||
|
||||
it('commits description', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(6, 'description', '')
|
||||
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', '')
|
||||
})
|
||||
|
||||
it('commits coinanimation', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(7, 'coinanimation', true)
|
||||
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', true)
|
||||
})
|
||||
|
||||
it('commits newsletterState', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', null)
|
||||
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', null)
|
||||
})
|
||||
|
||||
it('commits hasElopage', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'hasElopage', false)
|
||||
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false)
|
||||
})
|
||||
|
||||
it('commits publisherId', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', null)
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', null)
|
||||
})
|
||||
|
||||
it('commits isAdmin', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', false)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', false)
|
||||
})
|
||||
|
||||
// how to get this working?
|
||||
|
||||
@ -19,7 +19,6 @@ describe('UserCard_FormUserData', () => {
|
||||
state: {
|
||||
firstName: 'Peter',
|
||||
lastName: 'Lustig',
|
||||
description: '',
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
@ -59,10 +58,6 @@ describe('UserCard_FormUserData', () => {
|
||||
expect(wrapper.findAll('div.col').at(4).text()).toBe('Lustig')
|
||||
})
|
||||
|
||||
it('renders the description', () => {
|
||||
expect(wrapper.findAll('div.col').at(6).text()).toBe('')
|
||||
})
|
||||
|
||||
describe('edit user data', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.find('svg.bi-pencil').trigger('click')
|
||||
@ -80,11 +75,9 @@ describe('UserCard_FormUserData', () => {
|
||||
it('does not change the userdate when cancel is clicked', async () => {
|
||||
await wrapper.findAll('input').at(0).setValue('Petra')
|
||||
await wrapper.findAll('input').at(1).setValue('Lustiger')
|
||||
await wrapper.find('textarea').setValue('Keine Nickelbrille')
|
||||
await wrapper.find('svg.bi-x-circle').trigger('click')
|
||||
expect(wrapper.findAll('div.col').at(2).text()).toBe('Peter')
|
||||
expect(wrapper.findAll('div.col').at(4).text()).toBe('Lustig')
|
||||
expect(wrapper.findAll('div.col').at(6).text()).toBe('')
|
||||
})
|
||||
|
||||
it('has a submit button', () => {
|
||||
@ -108,7 +101,6 @@ describe('UserCard_FormUserData', () => {
|
||||
jest.clearAllMocks()
|
||||
await wrapper.findAll('input').at(0).setValue('Petra')
|
||||
await wrapper.findAll('input').at(1).setValue('Lustiger')
|
||||
await wrapper.find('textarea').setValue('Keine Nickelbrille')
|
||||
await wrapper.find('form').trigger('keyup')
|
||||
await wrapper.find('button[type="submit"]').trigger('click')
|
||||
await flushPromises()
|
||||
@ -120,7 +112,6 @@ describe('UserCard_FormUserData', () => {
|
||||
variables: {
|
||||
firstName: 'Petra',
|
||||
lastName: 'Lustiger',
|
||||
description: 'Keine Nickelbrille',
|
||||
},
|
||||
}),
|
||||
)
|
||||
@ -134,10 +125,6 @@ describe('UserCard_FormUserData', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('lastName', 'Lustiger')
|
||||
})
|
||||
|
||||
it('commits description to store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('description', 'Keine Nickelbrille')
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('settings.name.change-success')
|
||||
})
|
||||
@ -155,7 +142,6 @@ describe('UserCard_FormUserData', () => {
|
||||
jest.clearAllMocks()
|
||||
await wrapper.findAll('input').at(0).setValue('Petra')
|
||||
await wrapper.findAll('input').at(1).setValue('Lustiger')
|
||||
await wrapper.find('textarea').setValue('Keine Nickelbrille')
|
||||
await wrapper.find('form').trigger('keyup')
|
||||
await wrapper.find('button[type="submit"]').trigger('click')
|
||||
await flushPromises()
|
||||
@ -167,7 +153,6 @@ describe('UserCard_FormUserData', () => {
|
||||
variables: {
|
||||
firstName: 'Petra',
|
||||
lastName: 'Lustiger',
|
||||
description: 'Keine Nickelbrille',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user