From 421ae60507e5b8cfdf458eaac418fee86980ad2d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 22 Mar 2022 18:25:58 +0100 Subject: [PATCH] reset transaction formular emits set transaction with empty data --- .../src/components/GddSend/TransactionForm.spec.js | 12 +++++++++++- frontend/src/components/GddSend/TransactionForm.vue | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index 49b2174e0..51b2d0943 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -200,7 +200,7 @@ describe('GddSend', () => { expect(wrapper.find('button[type="reset"]').text()).toBe('form.reset') }) - it('clears all fields on click', async () => { + it('clears all fields on click and emits set-transaction', async () => { await wrapper.find('#input-group-1').find('input').setValue('someone@watches.tv') await wrapper.find('#input-group-2').find('input').setValue('87.23') await wrapper.find('#input-group-3').find('textarea').setValue('Long enough') @@ -213,6 +213,16 @@ describe('GddSend', () => { expect(wrapper.vm.form.email).toBe('') expect(wrapper.vm.form.amount).toBe('') expect(wrapper.vm.form.memo).toBe('') + expect(wrapper.emitted('set-transaction')).toEqual([ + [ + { + selected: 'send', + email: '', + amount: 0, + memo: '', + }, + ], + ]) }) }) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index c1acf9925..184c13f91 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -192,6 +192,12 @@ export default { this.form.email = '' this.form.amount = '' this.form.memo = '' + this.$emit('set-transaction', { + selected: this.selected, + email: '', + amount: 0, + memo: '', + }) }, normalizeAmount(isValid) { this.amountFocused = false