diff --git a/admin/src/components/ContributionLink.spec.js b/admin/src/components/ContributionLink.spec.js index 3fa7c6f4d..f1b9cfb97 100644 --- a/admin/src/components/ContributionLink.spec.js +++ b/admin/src/components/ContributionLink.spec.js @@ -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', () => { diff --git a/admin/src/components/ContributionLink.vue b/admin/src/components/ContributionLink.vue index 9321a2705..893e202f4 100644 --- a/admin/src/components/ContributionLink.vue +++ b/admin/src/components/ContributionLink.vue @@ -43,11 +43,11 @@ export default { props: { items: { type: Array, - default: () => [], + required: true, }, count: { type: Number, - default: 0, + required: true, }, }, data: function () { diff --git a/admin/src/components/ContributionLinkForm.spec.js b/admin/src/components/ContributionLinkForm.spec.js index f92831e84..849d6a9da 100644 --- a/admin/src/components/ContributionLinkForm.spec.js +++ b/admin/src/components/ContributionLinkForm.spec.js @@ -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() + }) }) }) }) diff --git a/admin/src/components/ContributionLinkList.spec.js b/admin/src/components/ContributionLinkList.spec.js index 8b93dab7d..0b9d131bd 100644 --- a/admin/src/components/ContributionLinkList.spec.js +++ b/admin/src/components/ContributionLinkList.spec.js @@ -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() }) }) }) diff --git a/admin/src/components/ContributionLinkList.vue b/admin/src/components/ContributionLinkList.vue index 3094386e0..518d7d57e 100644 --- a/admin/src/components/ContributionLinkList.vue +++ b/admin/src/components/ContributionLinkList.vue @@ -17,7 +17,12 @@ @@ -49,7 +54,7 @@ export default { FigureQrCode, }, props: { - items: { type: Array, default: () => [] }, + items: { type: Array, required: true }, }, data() { return { diff --git a/admin/src/components/FigureQrCode.vue b/admin/src/components/FigureQrCode.vue index eb5e07409..11a11d98c 100644 --- a/admin/src/components/FigureQrCode.vue +++ b/admin/src/components/FigureQrCode.vue @@ -22,6 +22,9 @@ export default { cellSize: 8, correctLevel: 'H', data: this.link, + logo: { + image: null, + }, }, } }, diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 6952288fb..2b41a9b96 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -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]) + }) }) }) })