mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test creation confitmation by clicks instead of emits
This commit is contained in:
parent
93522285f3
commit
301ceb38a8
@ -78,6 +78,7 @@ describe('CreationConfirm', () => {
|
|||||||
it('commits resetOpenCreations to store', () => {
|
it('commits resetOpenCreations to store', () => {
|
||||||
expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
|
expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits setOpenCreations to store', () => {
|
it('commits setOpenCreations to store', () => {
|
||||||
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2)
|
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2)
|
||||||
})
|
})
|
||||||
@ -85,7 +86,7 @@ describe('CreationConfirm', () => {
|
|||||||
|
|
||||||
describe('remove creation with success', () => {
|
describe('remove creation with success', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 })
|
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the deletePendingCreation mutation', () => {
|
it('calls the deletePendingCreation mutation', () => {
|
||||||
@ -107,7 +108,7 @@ describe('CreationConfirm', () => {
|
|||||||
describe('remove creation with error', () => {
|
describe('remove creation with error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
|
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
|
||||||
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 })
|
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
@ -118,22 +119,52 @@ describe('CreationConfirm', () => {
|
|||||||
describe('confirm creation with success', () => {
|
describe('confirm creation with success', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMutateMock.mockResolvedValue({})
|
apolloMutateMock.mockResolvedValue({})
|
||||||
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('confirm-creation', { id: 2 })
|
await wrapper.findAll('tr').at(2).findAll('button').at(2).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the confirmPendingCreation mutation', () => {
|
describe('overlay', () => {
|
||||||
expect(apolloMutateMock).toBeCalledWith({
|
it('opens the overlay', () => {
|
||||||
mutation: confirmPendingCreation,
|
expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
|
||||||
variables: { id: 2 },
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('commits openCreationsMinus to store', () => {
|
describe('cancel confirmation', () => {
|
||||||
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
beforeEach(async () => {
|
||||||
})
|
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
|
||||||
|
})
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
it('closes the overlay', () => {
|
||||||
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
|
expect(wrapper.find('#overlay').isVisible()).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('still has 2 items in the table', () => {
|
||||||
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('confirm creation', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls the confirmPendingCreation mutation', () => {
|
||||||
|
expect(apolloMutateMock).toBeCalledWith({
|
||||||
|
mutation: confirmPendingCreation,
|
||||||
|
variables: { id: 2 },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('commits openCreationsMinus to store', () => {
|
||||||
|
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('toasts a success message', () => {
|
||||||
|
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has 1 item left in the table', () => {
|
||||||
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user