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),
|
$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', () => {
|
||||||
|
|||||||
@ -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 () {
|
||||||
|
|||||||
@ -29,36 +29,40 @@ 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', () => {
|
||||||
beforeEach(() => {
|
it('form has the set data', () => {
|
||||||
wrapper.setData({
|
beforeEach(() => {
|
||||||
form: {
|
wrapper.setData({
|
||||||
name: 'name',
|
form: {
|
||||||
memo: 'memo',
|
name: 'name',
|
||||||
amount: 100,
|
memo: 'memo',
|
||||||
validFrom: 'validFrom',
|
amount: 100,
|
||||||
validTo: 'validTo',
|
validFrom: 'validFrom',
|
||||||
cycle: 'ONCE',
|
validTo: 'validTo',
|
||||||
maxPerCycle: 1,
|
cycle: 'ONCE',
|
||||||
maxAmountPerMonth: 100,
|
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', () => {
|
describe.skip('call onSubmit', () => {
|
||||||
wrapper.vm.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)
|
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,16 +83,16 @@ 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,
|
||||||
// variables: {
|
// variables: {
|
||||||
// id: 1,
|
// id: 1,
|
||||||
// },
|
// },
|
||||||
// }),
|
// }),
|
||||||
// )
|
// )
|
||||||
// })
|
})
|
||||||
|
|
||||||
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: [
|
amount: '200',
|
||||||
{
|
cycle: 'täglich',
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Meditation',
|
link: 'https://localhost/redeem/CL-1a2345678',
|
||||||
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
|
maxAmountPerMonth: 0,
|
||||||
amount: '200',
|
maxPerCycle: '3',
|
||||||
validFrom: '2022-04-01',
|
memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l',
|
||||||
validTo: '2022-08-01',
|
name: 'Meditation',
|
||||||
cycle: 'täglich',
|
validFrom: '2022-04-01',
|
||||||
maxPerCycle: '3',
|
validTo: '2022-08-01',
|
||||||
maxAmountPerMonth: 0,
|
|
||||||
link: 'https://localhost/redeem/CL-1a2345678',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
wrapper.vm.showContributionLink()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows modalData', () => {
|
|
||||||
expect(wrapper.emitted('modalData')).toEqual()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -22,6 +22,9 @@ export default {
|
|||||||
cellSize: 8,
|
cellSize: 8,
|
||||||
correctLevel: 'H',
|
correctLevel: 'H',
|
||||||
data: this.link,
|
data: this.link,
|
||||||
|
logo: {
|
||||||
|
image: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user