Merge pull request #2550 from gradido/2547-normalized-amount-transaction-is-processed-again

fix(frontend): normalized amount transaction if processed again
This commit is contained in:
Alexander Friedland 2023-01-17 16:20:56 +01:00 committed by GitHub
commit 79faae526c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -23,6 +23,7 @@ describe('ContributionForm', () => {
const mocks = { const mocks = {
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => d),
$n: jest.fn((n) => n),
$store: { $store: {
state: { state: {
creation: ['1000', '1000', '1000'], creation: ['1000', '1000', '1000'],

View File

@ -9,10 +9,10 @@ describe('InputAmount', () => {
const mocks = { const mocks = {
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$n: jest.fn((n) => n),
$i18n: { $i18n: {
locale: jest.fn(() => 'en'), locale: jest.fn(() => 'en'),
}, },
$n: jest.fn((n) => String(n)),
$route: { $route: {
params: {}, params: {},
}, },
@ -46,13 +46,14 @@ describe('InputAmount', () => {
describe('amount normalization', () => { describe('amount normalization', () => {
describe('if invalid', () => { describe('if invalid', () => {
beforeEach(() => { beforeEach(async () => {
await wrapper.setProps({ value: '12m34' })
valid = false valid = false
}) })
it('is not normalized', () => { it('is not normalized', () => {
wrapper.vm.normalizeAmount(valid) wrapper.vm.normalizeAmount(false)
expect(wrapper.vm.amountValue).toBe(0.0) expect(wrapper.vm.currentValue).toBe('12m34')
}) })
}) })
@ -97,13 +98,14 @@ describe('InputAmount', () => {
describe('amount normalization', () => { describe('amount normalization', () => {
describe('if invalid', () => { describe('if invalid', () => {
beforeEach(() => { beforeEach(async () => {
await wrapper.setProps({ value: '12m34' })
valid = false valid = false
}) })
it('is not normalized', () => { it('is not normalized', () => {
wrapper.vm.normalizeAmount(valid) wrapper.vm.normalizeAmount(valid)
expect(wrapper.vm.amountValue).toBe(0.0) expect(wrapper.vm.currentValue).toBe('12m34')
}) })
}) })

View File

@ -20,7 +20,7 @@
trim trim
v-focus="amountFocused" v-focus="amountFocused"
@focus="amountFocused = true" @focus="amountFocused = true"
@blur="normalizeAmount(true)" @blur="normalizeAmount(valid)"
:disabled="disabled" :disabled="disabled"
autocomplete="off" autocomplete="off"
></b-form-input> ></b-form-input>
@ -90,5 +90,8 @@ export default {
this.currentValue = this.$n(this.amountValue, 'ungroupedDecimal') this.currentValue = this.$n(this.amountValue, 'ungroupedDecimal')
}, },
}, },
mounted() {
if (this.value !== '') this.normalizeAmount(true)
},
} }
</script> </script>

View File

@ -13,7 +13,6 @@ export const verifyLogin = gql`
hasElopage hasElopage
publisherId publisherId
isAdmin isAdmin
creation
hideAmountGDD hideAmountGDD
hideAmountGDT hideAmountGDT
} }