From 8294e9ca8fb0411157b9cb2c1ce608efefb76395 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 8 Jun 2022 21:09:52 +0200 Subject: [PATCH] changed test to 95% --- .../components/ContributionLinkForm.spec.js | 39 ++++++++++++++----- admin/src/components/ContributionLinkForm.vue | 6 +-- .../Tables/OpenCreationsTable.spec.js | 5 +++ .../components/Tables/OpenCreationsTable.vue | 19 +++++++-- admin/src/locales/de.json | 1 - admin/src/locales/en.json | 1 - 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/admin/src/components/ContributionLinkForm.spec.js b/admin/src/components/ContributionLinkForm.spec.js index e53aabaa7..889ea69b4 100644 --- a/admin/src/components/ContributionLinkForm.spec.js +++ b/admin/src/components/ContributionLinkForm.spec.js @@ -3,10 +3,11 @@ import ContributionLinkForm from './ContributionLinkForm.vue' const localVue = global.localVue +global.alert = jest.fn() + const propsData = { contributionLinkData: {}, } -jest.spyOn(window, 'alert').mockReturnValue() const mocks = { $t: jest.fn((t) => t), @@ -25,19 +26,39 @@ describe('ContributionLinkForm', () => { }) it('renders the Div Element ".contribution-link-form"', () => { - expect(wrapper.find('div.contribution-link-form').exists()).toBeTruthy() - }) - - it('function onSubmit', () => { - wrapper.vm.onSubmit() + expect(wrapper.find('div.contribution-link-form').exists()).toBe(true) }) it('function onReset', () => { - wrapper.vm.onReset() + beforeEach(() => { + wrapper.setData({ + form: { + name: 'name', + memo: 'memo', + amount: 100, + startDate: 'startDate', + endDate: 'endDate', + cycle: 'cycle', + repetition: 'repetition', + maxAmount: 100, + }, + }) + wrapper.vm.onReset() + }) + expect(wrapper.vm.form).toEqual({ + amount: null, + cycle: null, + endDate: null, + maxAmount: null, + memo: null, + name: null, + repetition: null, + startDate: null, + }) }) - it('function updateForm', () => { - wrapper.vm.updateForm() + it('onSubmit valid form', () => { + wrapper.vm.onSubmit() }) }) }) diff --git a/admin/src/components/ContributionLinkForm.vue b/admin/src/components/ContributionLinkForm.vue index 8245c5320..f36839c57 100644 --- a/admin/src/components/ContributionLinkForm.vue +++ b/admin/src/components/ContributionLinkForm.vue @@ -134,7 +134,6 @@ export default { min: new Date(), cycle: [ { value: null, text: this.$t('contributionLink.options.cycle.null') }, - { value: 'none', text: this.$t('contributionLink.options.cycle.none') }, { value: 'hourly', text: this.$t('contributionLink.options.cycle.hourly') }, { value: 'daily', text: this.$t('contributionLink.options.cycle.daily') }, { value: 'weekly', text: this.$t('contributionLink.options.cycle.weekly') }, @@ -142,7 +141,7 @@ export default { { value: 'yearly', text: this.$t('contributionLink.options.cycle.yearly') }, ], repetition: [ - { value: null, text: 'Please select an repetition' }, + { value: null, text: this.$t('contributionLink.options.repetition.null') }, { value: '1', text: '1 x' }, { value: '2', text: '2 x' }, { value: '3', text: '3 x' }, @@ -184,9 +183,6 @@ export default { this.form.startDate = null this.form.endDate = null }, - updateForm() { - alert('updateForm') - }, }, computed: { updateData() { diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 9ff348562..ad28a6fb5 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -69,6 +69,7 @@ const propsData = { { key: 'edit_creation', label: 'edit' }, { key: 'confirm', label: 'save' }, ], + toggleDetails: false, } const mocks = { @@ -125,5 +126,9 @@ describe('OpenCreationsTable', () => { expect(wrapper.find('div.component-edit-creation-formular').exists()).toBeTruthy() }) }) + + it('funtion updateUserData', () => { + wrapper.vm.updateUserData([111, 222, 333], [444, 555, 666]) + }) }) }) diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index d2e9669e6..1e61f00b0 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -70,12 +70,23 @@ export default { required: true, }, }, + data() { + return { + creationUserData: { + amount: null, + date: null, + memo: null, + moderator: null, + }, + } + }, methods: { updateCreationData(data) { - this.creationUserData.amount = data.amount - this.creationUserData.date = data.date - this.creationUserData.memo = data.memo - this.creationUserData.moderator = data.moderator + this.creationUserData = data + // this.creationUserData.amount = data.amount + // this.creationUserData.date = data.date + // this.creationUserData.memo = data.memo + // this.creationUserData.moderator = data.moderator data.row.toggleDetails() }, updateUserData(rowItem, newCreation) { diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index e808103e2..b8e4347bf 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -21,7 +21,6 @@ "daily": "täglich", "hourly": "stündlich", "monthly": "monatlich", - "none": "kein Zyklus", "null": "Bitter wähle einen Zyklus", "weekly": "wöchentlich", "yearly": "jährlich" diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 0df90413a..7608caa1f 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -21,7 +21,6 @@ "daily": "daily", "hourly": "hourly", "monthly": "monthly", - "none": "no cycle", "null": "please select a cycle", "weekly": "weekly", "yearly": "yearly"