mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
feat: Test Creation in Admin Interface
This commit is contained in:
parent
dddd467569
commit
d9f8387d7e
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -441,7 +441,7 @@ jobs:
|
||||
report_name: Coverage Admin Interface
|
||||
type: lcov
|
||||
result_path: ./coverage/lcov.info
|
||||
min_coverage: 69
|
||||
min_coverage: 76
|
||||
token: ${{ github.token }}
|
||||
|
||||
##############################################################################
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import Creation from './Creation.vue'
|
||||
import Vue from 'vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -7,11 +8,19 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
searchUsers: [
|
||||
{
|
||||
id: 1,
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
email: 'bibi@bloxberg.de',
|
||||
creation: [200, 400, 600],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
@ -31,10 +40,10 @@ describe('Creation', () => {
|
||||
let wrapper
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(Creation, { localVue, mocks })
|
||||
return shallowMount(Creation, { localVue, mocks })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
describe('shallowMount', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
@ -43,6 +52,165 @@ describe('Creation', () => {
|
||||
expect(wrapper.find('div.creation').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
describe('apollo returns user array', () => {
|
||||
it('calls the searchUser query', () => {
|
||||
expect(apolloQueryMock).toBeCalled()
|
||||
})
|
||||
|
||||
it('sets the data of itemsList', () => {
|
||||
expect(wrapper.vm.itemsList).toEqual([
|
||||
{
|
||||
id: 1,
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
email: 'bibi@bloxberg.de',
|
||||
creation: [200, 400, 600],
|
||||
showDetails: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('update iten', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('push', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.findComponent({ name: 'UserTable' }).vm.$emit(
|
||||
'update-item',
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
'push',
|
||||
)
|
||||
})
|
||||
|
||||
it('removes the pushed item from itemsList', () => {
|
||||
expect(wrapper.vm.itemsList).toEqual([
|
||||
{
|
||||
id: 1,
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
email: 'bibi@bloxberg.de',
|
||||
creation: [200, 400, 600],
|
||||
showDetails: false,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('adds the pushed item to itemsMassCreation', () => {
|
||||
expect(wrapper.vm.itemsMassCreation).toEqual([
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
describe('remove', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.findComponent({ name: 'UserTable' }).vm.$emit(
|
||||
'update-item',
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
'remove',
|
||||
)
|
||||
})
|
||||
|
||||
it('removes the item from itemsMassCreation', () => {
|
||||
expect(wrapper.vm.itemsMassCreation).toEqual([])
|
||||
})
|
||||
|
||||
it('adds the item to itemsList', () => {
|
||||
expect(wrapper.vm.itemsList).toEqual([
|
||||
{
|
||||
id: 1,
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
email: 'bibi@bloxberg.de',
|
||||
creation: [200, 400, 600],
|
||||
showDetails: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('error', () => {
|
||||
const consoleErrorMock = jest.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
Vue.config.warnHandler = (w) => {}
|
||||
// eslint-disable-next-line no-console
|
||||
console.error = consoleErrorMock
|
||||
wrapper.findComponent({ name: 'UserTable' }).vm.$emit('update-item', {}, 'no-rule')
|
||||
})
|
||||
|
||||
it('throws an error', () => {
|
||||
expect(consoleErrorMock).toBeCalledWith(expect.objectContaining({ message: 'no-rule' }))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('remove all bookmarks', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit(
|
||||
'update-item',
|
||||
{
|
||||
id: 2,
|
||||
firstName: 'Benjamin',
|
||||
lastName: 'Blümchen',
|
||||
email: 'benjamin@bluemchen.de',
|
||||
creation: [800, 600, 400],
|
||||
showDetails: false,
|
||||
},
|
||||
'push',
|
||||
)
|
||||
wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark')
|
||||
})
|
||||
|
||||
it('removes all items from itemsMassCreation', () => {
|
||||
expect(wrapper.vm.itemsMassCreation).toEqual([])
|
||||
})
|
||||
|
||||
it('adds all items to itemsList', () => {
|
||||
expect(wrapper.vm.itemsList).toHaveLength(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('apollo returns error', () => {
|
||||
beforeEach(() => {
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
|
||||
@ -125,20 +125,9 @@ export default {
|
||||
throw new Error(event)
|
||||
}
|
||||
},
|
||||
|
||||
// updateRadioSelected(obj) {
|
||||
// this.radioSelectedMass = obj[0]
|
||||
// },
|
||||
|
||||
removeAllBookmark() {
|
||||
alert('remove all bookmarks')
|
||||
const index = 0
|
||||
let i = 0
|
||||
|
||||
for (i; i < this.itemsMassCreation.length; i++) {
|
||||
this.itemsList.push(this.itemsMassCreation[i])
|
||||
}
|
||||
this.itemsMassCreation.splice(index, this.itemsMassCreation.length)
|
||||
this.itemsMassCreation.forEach((item) => this.itemsList.push(item))
|
||||
this.itemsMassCreation = []
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user