add DeletedUserFormular.spec.js for tests

This commit is contained in:
ogerly 2022-02-23 14:12:10 +01:00
parent cd4a326ab7
commit 15b2bc30f7
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,56 @@
import { mount } from '@vue/test-utils'
import DeletedUserFormular from './DeletedUserFormular.vue'
import { deleteUser } from '../graphql/deleteUser'
import { unDeleteUser } from '../graphql/unDeleteUser'
const localVue = global.localVue
const apolloMutateMock = jest.fn().mockResolvedValue({
data: {
deleteUser: { userId: 1, deletedAt: new Date() },
unDeleteUser: { userId: 1, deletedAt: null },
},
})
const toastedErrorMock = jest.fn()
const toastedSuccessMock = jest.fn()
const mocks = {
$t: jest.fn(),
$apollo: {
mutate: apolloMutateMock,
},
$store: {
state: {
moderator: {
id: 0,
name: 'test moderator',
},
},
},
$toasted: {
error: toastedErrorMock,
success: toastedSuccessMock,
},
}
const propsData = {
item: {},
}
describe('DeletedUserFormular', () => {
let wrapper
const Wrapper = () => {
return mount(DeletedUserFormular, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
it('has a DIV element with the class.delete-user-formular', () => {
expect(wrapper.find('.deleted-user-formular').exists()).toBeTruthy()
})
})
})

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="deleted-user-formular">
<div v-if="item.userId === $store.state.moderator.id" class="mt-5 mb-5">
{{ $t('removeNotSelf') }}
</div>