From 94afc8f634f73b3b54b670af762748e2997889a9 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 5 Dec 2022 17:05:54 +0100 Subject: [PATCH] add tests for LastName.spec.js FirstName.spec.js --- .../components/GddSend/TransactionForm.vue | 12 ++--- .../src/components/Inputs/FirstName.spec.js | 38 ++++++++++++++ .../src/components/Inputs/InputAmount.spec.js | 41 +++++++++++++++ .../src/components/Inputs/InputAmount.vue | 52 ++++++++++--------- .../src/components/Inputs/LastName.spec.js | 38 ++++++++++++++ frontend/src/pages/Send.spec.js | 2 +- 6 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 frontend/src/components/Inputs/FirstName.spec.js create mode 100644 frontend/src/components/Inputs/InputAmount.spec.js create mode 100644 frontend/src/components/Inputs/LastName.spec.js diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index b2dd4a5a7..d11347c45 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -151,12 +151,12 @@ export default { this.form.amount = '' this.form.memo = '' }, - normalizeAmount(isValid) { - this.amountFocused = false - if (!isValid) return - this.form.amountValue = Number(this.form.amount.replace(',', '.')) - this.form.amount = this.$n(this.form.amountValue, 'ungroupedDecimal') - }, + // normalizeAmount(isValid) { + // this.amountFocused = false + // if (!isValid) return + // this.form.amountValue = Number(this.form.amount.replace(',', '.')) + // this.form.amount = this.$n(this.form.amountValue, 'ungroupedDecimal') + // }, normalizeEmail() { this.emailFocused = false this.form.email = this.form.email.trim() diff --git a/frontend/src/components/Inputs/FirstName.spec.js b/frontend/src/components/Inputs/FirstName.spec.js new file mode 100644 index 000000000..070850dbd --- /dev/null +++ b/frontend/src/components/Inputs/FirstName.spec.js @@ -0,0 +1,38 @@ +import { mount } from '@vue/test-utils' +import FirstName from './FirstName' + +const localVue = global.localVue + +describe('FirstName', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + $i18n: { + locale: jest.fn(() => 'en'), + }, + $n: jest.fn((n) => String(n)), + } + + const propsData = { + balance: 0.0, + } + + const Wrapper = () => { + return mount(FirstName, { + localVue, + mocks, + propsData, + }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component', () => { + expect(wrapper.find('div.first-name').exists()).toBe(true) + }) + }) +}) diff --git a/frontend/src/components/Inputs/InputAmount.spec.js b/frontend/src/components/Inputs/InputAmount.spec.js new file mode 100644 index 000000000..f2fc48888 --- /dev/null +++ b/frontend/src/components/Inputs/InputAmount.spec.js @@ -0,0 +1,41 @@ +import { mount } from '@vue/test-utils' +import InputAmount from './InputAmount' + +const localVue = global.localVue + +describe('InputAmount', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + $i18n: { + locale: jest.fn(() => 'en'), + }, + $n: jest.fn((n) => String(n)), + } + + const propsData = { + name: '', + label: '', + placeholder: '', + value: '', + } + + const Wrapper = () => { + return mount(InputAmount, { + localVue, + mocks, + propsData, + }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component input-amount', () => { + expect(wrapper.find('div.input-amount').exists()).toBe(true) + }) + }) +}) diff --git a/frontend/src/components/Inputs/InputAmount.vue b/frontend/src/components/Inputs/InputAmount.vue index 9270e38a8..b7c7c0da4 100644 --- a/frontend/src/components/Inputs/InputAmount.vue +++ b/frontend/src/components/Inputs/InputAmount.vue @@ -1,29 +1,31 @@