mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
changed code for review from wolle
This commit is contained in:
parent
188a93c6bd
commit
1a1d71e52f
@ -7,11 +7,29 @@ const mocks = {
|
||||
$t: jest.fn((t) => t),
|
||||
}
|
||||
|
||||
const propsData = {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Meditation',
|
||||
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
|
||||
amount: '200',
|
||||
validFrom: '2022-04-01',
|
||||
validTo: '2022-08-01',
|
||||
cycle: 'täglich',
|
||||
maxPerCycle: '3',
|
||||
maxAmountPerMonth: 0,
|
||||
link: 'https://localhost/redeem/CL-1a2345678',
|
||||
},
|
||||
],
|
||||
count: 1,
|
||||
}
|
||||
|
||||
describe('ContributionLink', () => {
|
||||
let wrapper
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(ContributionLink, { localVue, mocks })
|
||||
return mount(ContributionLink, { localVue, mocks, propsData })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
@ -43,11 +43,11 @@ export default {
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
required: true,
|
||||
},
|
||||
count: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data: function () {
|
||||
|
||||
@ -29,36 +29,40 @@ describe('ContributionLinkForm', () => {
|
||||
expect(wrapper.find('div.contribution-link-form').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('function onReset', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.setData({
|
||||
form: {
|
||||
name: 'name',
|
||||
memo: 'memo',
|
||||
amount: 100,
|
||||
validFrom: 'validFrom',
|
||||
validTo: 'validTo',
|
||||
cycle: 'ONCE',
|
||||
maxPerCycle: 1,
|
||||
maxAmountPerMonth: 100,
|
||||
},
|
||||
describe('call onReset', () => {
|
||||
it('form has the set data', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.setData({
|
||||
form: {
|
||||
name: 'name',
|
||||
memo: 'memo',
|
||||
amount: 100,
|
||||
validFrom: 'validFrom',
|
||||
validTo: 'validTo',
|
||||
cycle: 'ONCE',
|
||||
maxPerCycle: 1,
|
||||
maxAmountPerMonth: 100,
|
||||
},
|
||||
})
|
||||
wrapper.vm.onReset()
|
||||
})
|
||||
expect(wrapper.vm.form).toEqual({
|
||||
amount: null,
|
||||
cycle: 'ONCE',
|
||||
validTo: null,
|
||||
maxAmountPerMonth: '0',
|
||||
memo: null,
|
||||
name: null,
|
||||
maxPerCycle: 1,
|
||||
validFrom: null,
|
||||
})
|
||||
wrapper.vm.onReset()
|
||||
})
|
||||
expect(wrapper.vm.form).toEqual({
|
||||
amount: null,
|
||||
cycle: 'ONCE',
|
||||
validTo: null,
|
||||
maxAmountPerMonth: '0',
|
||||
memo: null,
|
||||
name: null,
|
||||
maxPerCycle: 1,
|
||||
validFrom: null,
|
||||
})
|
||||
})
|
||||
|
||||
it('onSubmit valid form', () => {
|
||||
wrapper.vm.onSubmit()
|
||||
describe.skip('call onSubmit', () => {
|
||||
it('response with the contribution link url', () => {
|
||||
wrapper.vm.onSubmit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -47,11 +47,17 @@ describe('ContributionLinkList', () => {
|
||||
expect(wrapper.find('div.contribution-link-list').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('renders table with contribution link', () => {
|
||||
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
|
||||
'Meditation',
|
||||
)
|
||||
})
|
||||
|
||||
describe('edit contribution link', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
wrapper.vm.editContributionLink()
|
||||
})
|
||||
|
||||
it('emits editContributionLinkData', async () => {
|
||||
expect(wrapper.vm.$emit('editContributionLinkData')).toBeTruthy()
|
||||
})
|
||||
@ -77,16 +83,16 @@ describe('ContributionLinkList', () => {
|
||||
expect(spy).toBeCalled()
|
||||
})
|
||||
|
||||
// it('calls the API', () => {
|
||||
// expect(mockAPIcall).toBeCalledWith(
|
||||
// expect.objectContaining({
|
||||
// mutation: deleteContributionLink,
|
||||
// variables: {
|
||||
// id: 1,
|
||||
// },
|
||||
// }),
|
||||
// )
|
||||
// })
|
||||
it.skip('calls the API', () => {
|
||||
// expect(mockAPIcall).toBeCalledWith(
|
||||
// expect.objectContaining({
|
||||
// mutation: deleteContributionLink,
|
||||
// variables: {
|
||||
// id: 1,
|
||||
// },
|
||||
// }),
|
||||
// )
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessSpy).toBeCalledWith('TODO: request message deleted ')
|
||||
@ -120,30 +126,21 @@ describe('ContributionLinkList', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('show contribution link', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
wrapper.setData({
|
||||
modalData: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Meditation',
|
||||
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
|
||||
amount: '200',
|
||||
validFrom: '2022-04-01',
|
||||
validTo: '2022-08-01',
|
||||
cycle: 'täglich',
|
||||
maxPerCycle: '3',
|
||||
maxAmountPerMonth: 0,
|
||||
link: 'https://localhost/redeem/CL-1a2345678',
|
||||
},
|
||||
],
|
||||
describe('onClick showButton', () => {
|
||||
it('modelData contains contribution link', () => {
|
||||
wrapper.find('button.test-show').trigger('click')
|
||||
expect(wrapper.vm.modalData).toEqual({
|
||||
amount: '200',
|
||||
cycle: 'täglich',
|
||||
id: 1,
|
||||
link: 'https://localhost/redeem/CL-1a2345678',
|
||||
maxAmountPerMonth: 0,
|
||||
maxPerCycle: '3',
|
||||
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
|
||||
name: 'Meditation',
|
||||
validFrom: '2022-04-01',
|
||||
validTo: '2022-08-01',
|
||||
})
|
||||
wrapper.vm.showContributionLink()
|
||||
})
|
||||
|
||||
it('shows modalData', () => {
|
||||
expect(wrapper.emitted('modalData')).toEqual()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -17,7 +17,12 @@
|
||||
</b-button>
|
||||
</template>
|
||||
<template #cell(show)="data">
|
||||
<b-button variant="info" size="md" class="mr-2" @click="showContributionLink(data.item)">
|
||||
<b-button
|
||||
variant="info"
|
||||
size="md"
|
||||
class="mr-2 test-show"
|
||||
@click="showContributionLink(data.item)"
|
||||
>
|
||||
<b-icon icon="eye" variant="light"></b-icon>
|
||||
</b-button>
|
||||
</template>
|
||||
@ -49,7 +54,7 @@ export default {
|
||||
FigureQrCode,
|
||||
},
|
||||
props: {
|
||||
items: { type: Array, default: () => [] },
|
||||
items: { type: Array, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@ -22,6 +22,9 @@ export default {
|
||||
cellSize: 8,
|
||||
correctLevel: 'H',
|
||||
data: this.link,
|
||||
logo: {
|
||||
image: null,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@ -127,8 +127,12 @@ describe('OpenCreationsTable', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('funtion updateUserData', () => {
|
||||
wrapper.vm.updateUserData([111, 222, 333], [444, 555, 666])
|
||||
describe('call updateUserData', () => {
|
||||
it('user creations has updated data', async () => {
|
||||
wrapper.vm.updateUserData(propsData.items[0], [444, 555, 666])
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.vm.items[0].creation).toEqual([444, 555, 666])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user