changed code for review from wolle

This commit is contained in:
ogerly 2022-06-16 11:45:45 +02:00
parent 188a93c6bd
commit 1a1d71e52f
7 changed files with 98 additions and 67 deletions

View File

@ -7,11 +7,29 @@ const mocks = {
$t: jest.fn((t) => t), $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', () => { describe('ContributionLink', () => {
let wrapper let wrapper
const Wrapper = () => { const Wrapper = () => {
return mount(ContributionLink, { localVue, mocks }) return mount(ContributionLink, { localVue, mocks, propsData })
} }
describe('mount', () => { describe('mount', () => {

View File

@ -43,11 +43,11 @@ export default {
props: { props: {
items: { items: {
type: Array, type: Array,
default: () => [], required: true,
}, },
count: { count: {
type: Number, type: Number,
default: 0, required: true,
}, },
}, },
data: function () { data: function () {

View File

@ -29,7 +29,8 @@ describe('ContributionLinkForm', () => {
expect(wrapper.find('div.contribution-link-form').exists()).toBe(true) expect(wrapper.find('div.contribution-link-form').exists()).toBe(true)
}) })
it('function onReset', () => { describe('call onReset', () => {
it('form has the set data', () => {
beforeEach(() => { beforeEach(() => {
wrapper.setData({ wrapper.setData({
form: { form: {
@ -56,9 +57,12 @@ describe('ContributionLinkForm', () => {
validFrom: null, validFrom: null,
}) })
}) })
})
it('onSubmit valid form', () => { describe.skip('call onSubmit', () => {
it('response with the contribution link url', () => {
wrapper.vm.onSubmit() wrapper.vm.onSubmit()
}) })
}) })
}) })
})

View File

@ -47,11 +47,17 @@ describe('ContributionLinkList', () => {
expect(wrapper.find('div.contribution-link-list').exists()).toBe(true) 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', () => { describe('edit contribution link', () => {
beforeEach(() => { beforeEach(() => {
wrapper = Wrapper()
wrapper.vm.editContributionLink() wrapper.vm.editContributionLink()
}) })
it('emits editContributionLinkData', async () => { it('emits editContributionLinkData', async () => {
expect(wrapper.vm.$emit('editContributionLinkData')).toBeTruthy() expect(wrapper.vm.$emit('editContributionLinkData')).toBeTruthy()
}) })
@ -77,7 +83,7 @@ describe('ContributionLinkList', () => {
expect(spy).toBeCalled() expect(spy).toBeCalled()
}) })
// it('calls the API', () => { it.skip('calls the API', () => {
// expect(mockAPIcall).toBeCalledWith( // expect(mockAPIcall).toBeCalledWith(
// expect.objectContaining({ // expect.objectContaining({
// mutation: deleteContributionLink, // mutation: deleteContributionLink,
@ -86,7 +92,7 @@ describe('ContributionLinkList', () => {
// }, // },
// }), // }),
// ) // )
// }) })
it('toasts a success message', () => { it('toasts a success message', () => {
expect(toastSuccessSpy).toBeCalledWith('TODO: request message deleted ') expect(toastSuccessSpy).toBeCalledWith('TODO: request message deleted ')
@ -120,30 +126,21 @@ describe('ContributionLinkList', () => {
}) })
}) })
describe('show contribution link', () => { describe('onClick showButton', () => {
beforeEach(() => { it('modelData contains contribution link', () => {
wrapper = Wrapper() wrapper.find('button.test-show').trigger('click')
wrapper.setData({ expect(wrapper.vm.modalData).toEqual({
modalData: [
{
id: 1,
name: 'Meditation',
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
amount: '200', 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', validFrom: '2022-04-01',
validTo: '2022-08-01', validTo: '2022-08-01',
cycle: 'täglich', })
maxPerCycle: '3',
maxAmountPerMonth: 0,
link: 'https://localhost/redeem/CL-1a2345678',
},
],
})
wrapper.vm.showContributionLink()
})
it('shows modalData', () => {
expect(wrapper.emitted('modalData')).toEqual()
}) })
}) })
}) })

View File

@ -17,7 +17,12 @@
</b-button> </b-button>
</template> </template>
<template #cell(show)="data"> <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-icon icon="eye" variant="light"></b-icon>
</b-button> </b-button>
</template> </template>
@ -49,7 +54,7 @@ export default {
FigureQrCode, FigureQrCode,
}, },
props: { props: {
items: { type: Array, default: () => [] }, items: { type: Array, required: true },
}, },
data() { data() {
return { return {

View File

@ -22,6 +22,9 @@ export default {
cellSize: 8, cellSize: 8,
correctLevel: 'H', correctLevel: 'H',
data: this.link, data: this.link,
logo: {
image: null,
},
}, },
} }
}, },

View File

@ -127,8 +127,12 @@ describe('OpenCreationsTable', () => {
}) })
}) })
it('funtion updateUserData', () => { describe('call updateUserData', () => {
wrapper.vm.updateUserData([111, 222, 333], [444, 555, 666]) 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])
})
}) })
}) })
}) })