From 28fea1942da1e432b9fb3abe31602c9d7c7dc1bb Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 9 Mar 2022 15:42:10 +0100 Subject: [PATCH] test setChecked in TransactionForm, test for TransactionConfirmation --- .../GddSend/TransactionConfirmation.spec.js | 63 +++++++++++++++++++ .../GddSend/TransactionConfirmation.vue | 36 ++++------- .../GddSend/TransactionForm.spec.js | 14 +++-- .../components/GddSend/TransactionForm.vue | 19 +----- frontend/src/pages/Send.vue | 24 +------ 5 files changed, 85 insertions(+), 71 deletions(-) create mode 100644 frontend/src/components/GddSend/TransactionConfirmation.spec.js diff --git a/frontend/src/components/GddSend/TransactionConfirmation.spec.js b/frontend/src/components/GddSend/TransactionConfirmation.spec.js new file mode 100644 index 000000000..af746b6ff --- /dev/null +++ b/frontend/src/components/GddSend/TransactionConfirmation.spec.js @@ -0,0 +1,63 @@ +import { mount } from '@vue/test-utils' +import TransactionConfirmation from './TransactionConfirmation' + +const localVue = global.localVue + +describe('GddSend confirm', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + $i18n: { + locale: jest.fn(() => 'en'), + }, + $n: jest.fn((n) => String(n)), + } + + const propsData = { + balance: 1234, + email: 'user@example.org', + amount: 12.34, + memo: 'Pessimisten stehen im Regen, Optimisten duschen unter den Wolken.', + loading: false, + selected: 'send', + } + + const Wrapper = () => { + return mount(TransactionConfirmation, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component div.transaction-confirm', () => { + expect(wrapper.find('div.transaction-confirm').exists()).toBeTruthy() + }) + + describe('has selected "send"', () => { + beforeEach(async () => { + await wrapper.setProps({ + selected: 'send', + }) + }) + + it('renders the component div.confirm-box-send', () => { + expect(wrapper.find('div.confirm-box-send').exists()).toBeTruthy() + }) + }) + + describe('has selected "link"', () => { + beforeEach(async () => { + await wrapper.setProps({ + selected: 'link', + }) + }) + + it('renders the component div.confirm-box-link', () => { + expect(wrapper.findAll('div.confirm-box-link').at(0).exists()).toBeTruthy() + }) + }) + }) +}) diff --git a/frontend/src/components/GddSend/TransactionConfirmation.vue b/frontend/src/components/GddSend/TransactionConfirmation.vue index 1867597e5..b3e873748 100644 --- a/frontend/src/components/GddSend/TransactionConfirmation.vue +++ b/frontend/src/components/GddSend/TransactionConfirmation.vue @@ -1,6 +1,6 @@