diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 90db3a93f..ed3d33543 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -81,7 +81,7 @@ describe('CreationConfirm', () => { }) }) - describe('confirm creation delete with success', () => { + describe('delete creation delete with success', () => { beforeEach(async () => { apolloQueryMock.mockResolvedValue({ data: { @@ -130,7 +130,7 @@ describe('CreationConfirm', () => { }) }) - describe('confirm creation delete with error', () => { + describe('delete creation delete with error', () => { beforeEach(async () => { apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' }) await wrapper @@ -143,6 +143,68 @@ describe('CreationConfirm', () => { }) }) + describe('confirm creation delete with success', () => { + beforeEach(async () => { + apolloQueryMock.mockResolvedValue({ + data: { + getPendingCreations: [ + { + id: 1, + firstName: 'Bibi', + lastName: 'Bloxberg', + email: 'bibi@bloxberg.de', + amount: 500, + memo: 'Danke für alles', + date: new Date(), + moderator: 0, + }, + { + id: 2, + firstName: 'Räuber', + lastName: 'Hotzenplotz', + email: 'raeuber@hotzenplotz.de', + amount: 1000000, + memo: 'Gut Ergatert', + date: new Date(), + moderator: 0, + }, + ], + }, + }) + await wrapper + .findComponent({ name: 'UserTable' }) + .vm.$emit('remove-confirm-result', { id: 1 }, 'confirmed') + }) + + it('calls the deletePendingCreation mutation', () => { + expect(apolloMutateMock).not.toBeCalledWith({ + mutation: deletePendingCreation, + variables: { id: 1 }, + }) + }) + + it('commits openCreationsMinus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) + }) + + it('toasts a success message', () => { + expect(toastedSuccessMock).toBeCalledWith('Pending Creation has been deleted') + }) + }) + + describe('delete creation delete with error', () => { + beforeEach(async () => { + apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' }) + await wrapper + .findComponent({ name: 'UserTable' }) + .vm.$emit('remove-confirm-result', { id: 1 }, 'confirm') + }) + + it('toasts an error message', () => { + expect(toastedErrorMock).not.toBeCalledWith('Ouchhh!') + }) + }) + describe('server response is error', () => { beforeEach(() => { jest.clearAllMocks()