mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adapt delete user formular unit tests to changes
This commit is contained in:
parent
d685a01742
commit
941663af36
@ -35,6 +35,7 @@ const propsData = {
|
|||||||
|
|
||||||
describe('DeletedUserFormular', () => {
|
describe('DeletedUserFormular', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
let spy
|
||||||
|
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return mount(DeletedUserFormular, { localVue, mocks, propsData })
|
return mount(DeletedUserFormular, { localVue, mocks, propsData })
|
||||||
@ -62,6 +63,10 @@ describe('DeletedUserFormular', () => {
|
|||||||
it('shows a text that you cannot delete yourself', () => {
|
it('shows a text that you cannot delete yourself', () => {
|
||||||
expect(wrapper.text()).toBe('removeNotSelf')
|
expect(wrapper.text()).toBe('removeNotSelf')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('has no "delete_user" button', () => {
|
||||||
|
expect(wrapper.find('button').exists()).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('delete other user', () => {
|
describe('delete other user', () => {
|
||||||
@ -71,35 +76,32 @@ describe('DeletedUserFormular', () => {
|
|||||||
userId: 1,
|
userId: 1,
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
},
|
},
|
||||||
|
static: true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a checkbox', () => {
|
|
||||||
expect(wrapper.find('input[type="checkbox"]').exists()).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows the text "delete_user"', () => {
|
it('shows the text "delete_user"', () => {
|
||||||
expect(wrapper.text()).toBe('delete_user')
|
expect(wrapper.text()).toBe('delete_user')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('click on checkbox', () => {
|
it('has a "delete_user" button', () => {
|
||||||
|
expect(wrapper.find('button').text()).toBe('delete_user')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('click on "delete_user" button', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.find('input[type="checkbox"]').setChecked()
|
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
||||||
|
spy.mockImplementation(() => Promise.resolve(true))
|
||||||
|
await wrapper.find('button').trigger('click')
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a confirmation button', () => {
|
it('calls the modal', () => {
|
||||||
expect(wrapper.find('button').exists()).toBe(true)
|
expect(wrapper.emitted('showDeleteModal'))
|
||||||
})
|
expect(spy).toHaveBeenCalled()
|
||||||
|
|
||||||
it('has the button text "delete_user"', () => {
|
|
||||||
expect(wrapper.find('button').text()).toBe('delete_user')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm delete with success', () => {
|
describe('confirm delete with success', () => {
|
||||||
beforeEach(async () => {
|
|
||||||
await wrapper.find('button').trigger('click')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('calls the API', () => {
|
it('calls the API', () => {
|
||||||
expect(apolloMutateMock).toBeCalledWith(
|
expect(apolloMutateMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -123,32 +125,20 @@ describe('DeletedUserFormular', () => {
|
|||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unchecks the checkbox', () => {
|
|
||||||
expect(wrapper.find('input').attributes('checked')).toBe(undefined)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm delete with error', () => {
|
describe('confirm delete with error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
||||||
apolloMutateMock.mockRejectedValue({ message: 'Oh no!' })
|
apolloMutateMock.mockRejectedValue({ message: 'Oh no!' })
|
||||||
await wrapper.find('button').trigger('click')
|
await wrapper.find('button').trigger('click')
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastErrorSpy).toBeCalledWith('Oh no!')
|
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()).toBe(false)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -162,37 +152,33 @@ describe('DeletedUserFormular', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a checkbox', () => {
|
|
||||||
expect(wrapper.find('input[type="checkbox"]').exists()).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows the text "undelete_user"', () => {
|
it('shows the text "undelete_user"', () => {
|
||||||
expect(wrapper.text()).toBe('undelete_user')
|
expect(wrapper.text()).toBe('undelete_user')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('click on checkbox', () => {
|
it('has a "undelete_user" button', () => {
|
||||||
|
expect(wrapper.find('button').text()).toBe('undelete_user')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('click on "undelete_user" button', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMutateMock.mockResolvedValue({
|
apolloMutateMock.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
unDeleteUser: null,
|
unDeleteUser: null,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await wrapper.find('input[type="checkbox"]').setChecked()
|
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
||||||
|
spy.mockImplementation(() => Promise.resolve(true))
|
||||||
|
await wrapper.find('button').trigger('click')
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a confirmation button', () => {
|
it('calls the modal', () => {
|
||||||
expect(wrapper.find('button').exists()).toBe(true)
|
expect(wrapper.emitted('showUndeleteModal'))
|
||||||
})
|
expect(spy).toHaveBeenCalled()
|
||||||
|
|
||||||
it('has the button text "undelete_user"', () => {
|
|
||||||
expect(wrapper.find('button').text()).toBe('undelete_user')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm recover with success', () => {
|
describe('confirm recover with success', () => {
|
||||||
beforeEach(async () => {
|
|
||||||
await wrapper.find('button').trigger('click')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('calls the API', () => {
|
it('calls the API', () => {
|
||||||
expect(apolloMutateMock).toBeCalledWith(
|
expect(apolloMutateMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -205,7 +191,7 @@ describe('DeletedUserFormular', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('emits update deleted At', () => {
|
it('emits update deleted At', () => {
|
||||||
expect(wrapper.emitted('updateDeletedAt')).toEqual(
|
expect(wrapper.emitted('updateDeletedAt')).toMatchObject(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{
|
{
|
||||||
@ -216,10 +202,6 @@ describe('DeletedUserFormular', () => {
|
|||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unchecks the checkbox', () => {
|
|
||||||
expect(wrapper.find('input').attributes('checked')).toBe(undefined)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm recover with error', () => {
|
describe('confirm recover with error', () => {
|
||||||
@ -232,16 +214,6 @@ describe('DeletedUserFormular', () => {
|
|||||||
expect(toastErrorSpy).toBeCalledWith('Oh no!')
|
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()).toBe(false)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user