diff --git a/admin/src/components/DeletedUserFormular.spec.js b/admin/src/components/DeletedUserFormular.spec.js index 5c41831e5..210539b7b 100644 --- a/admin/src/components/DeletedUserFormular.spec.js +++ b/admin/src/components/DeletedUserFormular.spec.js @@ -49,198 +49,198 @@ describe('DeletedUserFormular', () => { it('has a DIV element with the class.delete-user-formular', () => { expect(wrapper.find('.deleted-user-formular').exists()).toBeTruthy() }) - }) - describe('delete self', () => { - beforeEach(() => { - wrapper.setProps({ - item: { - userId: 0, - }, - }) - }) - - it('shows a text that you cannot delete yourself', () => { - expect(wrapper.text()).toBe('removeNotSelf') - }) - }) - - describe('delete other user', () => { - beforeEach(() => { - wrapper.setProps({ - item: { - userId: 1, - deletedAt: null, - }, - }) - }) - - it('has a checkbox', () => { - expect(wrapper.find('input[type="checkbox"]').exists()).toBeTruthy() - }) - - it('shows the text "delete_user"', () => { - expect(wrapper.text()).toBe('delete_user') - }) - - describe('click on checkbox', () => { - beforeEach(async () => { - await wrapper.find('input[type="checkbox"]').setChecked() - }) - - it('has a confirmation button', () => { - expect(wrapper.find('button').exists()).toBeTruthy() - }) - - it('has the button text "delete_user"', () => { - expect(wrapper.find('button').text()).toBe('delete_user') - }) - - describe('confirm delete with success', () => { - beforeEach(async () => { - await wrapper.find('button').trigger('click') - }) - - it('calls the API', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - mutation: deleteUser, - variables: { - userId: 1, - }, - }), - ) - }) - - it('emits update deleted At', () => { - expect(wrapper.emitted('updateDeletedAt')).toEqual( - expect.arrayContaining([ - expect.arrayContaining([ - { - userId: 1, - deletedAt: date, - }, - ]), - ]), - ) - }) - - it('unchecks the checkbox', () => { - expect(wrapper.find('input').attributes('checked')).toBe(undefined) - }) - }) - - describe('confirm delete with error', () => { - beforeEach(async () => { - apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) - await wrapper.find('button').trigger('click') - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Oh no!') - }) - }) - - describe('click on checkbox again', () => { - beforeEach(async () => { - await wrapper.find('input[type="checkbox"]').setChecked(false) - }) - - it('has no confirmation button anymore', () => { - expect(wrapper.find('button').exists()).toBeFalsy() - }) - }) - }) - }) - - describe('recover user', () => { - beforeEach(() => { - wrapper.setProps({ - item: { - userId: 1, - deletedAt: date, - }, - }) - }) - - it('has a checkbox', () => { - expect(wrapper.find('input[type="checkbox"]').exists()).toBeTruthy() - }) - - it('shows the text "undelete_user"', () => { - expect(wrapper.text()).toBe('undelete_user') - }) - - describe('click on checkbox', () => { - beforeEach(async () => { - apolloMutateMock.mockResolvedValue({ - data: { - unDeleteUser: null, + describe('delete self', () => { + beforeEach(() => { + wrapper.setProps({ + item: { + userId: 0, }, }) - await wrapper.find('input[type="checkbox"]').setChecked() }) - it('has a confirmation button', () => { - expect(wrapper.find('button').exists()).toBeTruthy() + it('shows a text that you cannot delete yourself', () => { + expect(wrapper.text()).toBe('removeNotSelf') + }) + }) + + describe('delete other user', () => { + beforeEach(() => { + wrapper.setProps({ + item: { + userId: 1, + deletedAt: null, + }, + }) }) - it('has the button text "undelete_user"', () => { - expect(wrapper.find('button').text()).toBe('undelete_user') + it('has a checkbox', () => { + expect(wrapper.find('input[type="checkbox"]').exists()).toBeTruthy() }) - describe('confirm recover with success', () => { + it('shows the text "delete_user"', () => { + expect(wrapper.text()).toBe('delete_user') + }) + + describe('click on checkbox', () => { beforeEach(async () => { - await wrapper.find('button').trigger('click') + await wrapper.find('input[type="checkbox"]').setChecked() }) - it('calls the API', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - mutation: unDeleteUser, - variables: { - userId: 1, - }, - }), - ) + it('has a confirmation button', () => { + expect(wrapper.find('button').exists()).toBeTruthy() }) - it('emits update deleted At', () => { - expect(wrapper.emitted('updateDeletedAt')).toEqual( - expect.arrayContaining([ - expect.arrayContaining([ - { + it('has the button text "delete_user"', () => { + expect(wrapper.find('button').text()).toBe('delete_user') + }) + + describe('confirm delete with success', () => { + beforeEach(async () => { + await wrapper.find('button').trigger('click') + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + mutation: deleteUser, + variables: { userId: 1, - deletedAt: null, }, + }), + ) + }) + + it('emits update deleted At', () => { + expect(wrapper.emitted('updateDeletedAt')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + userId: 1, + deletedAt: date, + }, + ]), ]), - ]), - ) + ) + }) + + it('unchecks the checkbox', () => { + expect(wrapper.find('input').attributes('checked')).toBe(undefined) + }) }) - it('unchecks the checkbox', () => { - expect(wrapper.find('input').attributes('checked')).toBe(undefined) + describe('confirm delete with error', () => { + beforeEach(async () => { + apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + await wrapper.find('button').trigger('click') + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Oh no!') + }) + }) + + describe('click on checkbox again', () => { + beforeEach(async () => { + await wrapper.find('input[type="checkbox"]').setChecked(false) + }) + + it('has no confirmation button anymore', () => { + expect(wrapper.find('button').exists()).toBeFalsy() + }) + }) + }) + }) + + describe('recover user', () => { + beforeEach(() => { + wrapper.setProps({ + item: { + userId: 1, + deletedAt: date, + }, }) }) - describe('confirm recover with error', () => { - beforeEach(async () => { - apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) - await wrapper.find('button').trigger('click') - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Oh no!') - }) + it('has a checkbox', () => { + expect(wrapper.find('input[type="checkbox"]').exists()).toBeTruthy() }) - describe('click on checkbox again', () => { + it('shows the text "undelete_user"', () => { + expect(wrapper.text()).toBe('undelete_user') + }) + + describe('click on checkbox', () => { beforeEach(async () => { - await wrapper.find('input[type="checkbox"]').setChecked(false) + apolloMutateMock.mockResolvedValue({ + data: { + unDeleteUser: null, + }, + }) + await wrapper.find('input[type="checkbox"]').setChecked() }) - it('has no confirmation button anymore', () => { - expect(wrapper.find('button').exists()).toBeFalsy() + it('has a confirmation button', () => { + expect(wrapper.find('button').exists()).toBeTruthy() + }) + + it('has the button text "undelete_user"', () => { + expect(wrapper.find('button').text()).toBe('undelete_user') + }) + + describe('confirm recover with success', () => { + beforeEach(async () => { + await wrapper.find('button').trigger('click') + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + mutation: unDeleteUser, + variables: { + userId: 1, + }, + }), + ) + }) + + it('emits update deleted At', () => { + expect(wrapper.emitted('updateDeletedAt')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + userId: 1, + deletedAt: null, + }, + ]), + ]), + ) + }) + + it('unchecks the checkbox', () => { + expect(wrapper.find('input').attributes('checked')).toBe(undefined) + }) + }) + + describe('confirm recover with error', () => { + beforeEach(async () => { + apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + await wrapper.find('button').trigger('click') + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Oh no!') + }) + }) + + describe('click on checkbox again', () => { + beforeEach(async () => { + await wrapper.find('input[type="checkbox"]').setChecked(false) + }) + + it('has no confirmation button anymore', () => { + expect(wrapper.find('button').exists()).toBeFalsy() + }) }) }) })