mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into 2078-wallet-improvments
This commit is contained in:
commit
194bce760a
@ -45,8 +45,70 @@ describe('ContributionForm', () => {
|
|||||||
expect(wrapper.find('div.contribution-form').exists()).toBe(true)
|
expect(wrapper.find('div.contribution-form').exists()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('is submit button disable of true', () => {
|
describe('empty form data', () => {
|
||||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
describe('buttons', () => {
|
||||||
|
it('has reset enabled', () => {
|
||||||
|
expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has submit disabled', () => {
|
||||||
|
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('set contrubtion', () => {
|
||||||
|
describe('fill in form data', () => {
|
||||||
|
const now = new Date().toISOString()
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper.setData({
|
||||||
|
form: {
|
||||||
|
id: null,
|
||||||
|
date: now,
|
||||||
|
memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...',
|
||||||
|
amount: '200',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('buttons', () => {
|
||||||
|
it('has reset enabled', () => {
|
||||||
|
expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has submit enabled', () => {
|
||||||
|
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('update contrubtion', () => {
|
||||||
|
describe('fill in form data and "id"', () => {
|
||||||
|
const now = new Date().toISOString()
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper.setData({
|
||||||
|
form: {
|
||||||
|
id: 2,
|
||||||
|
date: now,
|
||||||
|
memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...',
|
||||||
|
amount: '200',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('buttons', () => {
|
||||||
|
it('has reset enabled', () => {
|
||||||
|
expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has submit enabled', () => {
|
||||||
|
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -74,13 +74,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<b-row class="mt-3">
|
<b-row class="mt-3">
|
||||||
<b-col>
|
<b-col>
|
||||||
<b-button type="button" variant="light" @click.prevent="reset">
|
<b-button class="test-cancel" type="reset" variant="secondary" @click="reset">
|
||||||
{{ $t('form.reset') }}
|
{{ $t('form.cancel') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col class="text-right">
|
<b-col class="text-right">
|
||||||
<b-button class="test-submit" type="submit" variant="primary" :disabled="disabled">
|
<b-button class="test-submit" type="submit" variant="primary" :disabled="disabled">
|
||||||
{{ value.id ? $t('form.edit') : $t('contribution.submit') }}
|
{{ form.id ? $t('form.change') : $t('contribution.submit') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
@ -99,13 +99,12 @@ export default {
|
|||||||
minlength: 5,
|
minlength: 5,
|
||||||
maxlength: 255,
|
maxlength: 255,
|
||||||
maximalDate: new Date(),
|
maximalDate: new Date(),
|
||||||
form: this.value,
|
form: this.value, // includes 'id'
|
||||||
id: this.value.id,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
if (this.value.id) {
|
if (this.form.id) {
|
||||||
this.$emit('update-contribution', this.form)
|
this.$emit('update-contribution', this.form)
|
||||||
} else {
|
} else {
|
||||||
this.$emit('set-contribution', this.form)
|
this.$emit('set-contribution', this.form)
|
||||||
@ -114,9 +113,10 @@ export default {
|
|||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.$refs.form.reset()
|
this.$refs.form.reset()
|
||||||
|
this.form.id = null
|
||||||
this.form.date = ''
|
this.form.date = ''
|
||||||
this.id = null
|
|
||||||
this.form.memo = ''
|
this.form.memo = ''
|
||||||
|
this.form.amount = ''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -159,13 +159,13 @@ export default {
|
|||||||
},
|
},
|
||||||
maxGddLastMonth() {
|
maxGddLastMonth() {
|
||||||
// When edited, the amount is added back on top of the amount
|
// When edited, the amount is added back on top of the amount
|
||||||
return this.value.id && !this.isThisMonth
|
return this.form.id && !this.isThisMonth
|
||||||
? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount)
|
? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount)
|
||||||
: this.$store.state.creation[1]
|
: this.$store.state.creation[1]
|
||||||
},
|
},
|
||||||
maxGddThisMonth() {
|
maxGddThisMonth() {
|
||||||
// When edited, the amount is added back on top of the amount
|
// When edited, the amount is added back on top of the amount
|
||||||
return this.value.id && this.isThisMonth
|
return this.form.id && this.isThisMonth
|
||||||
? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount)
|
? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount)
|
||||||
: this.$store.state.creation[2]
|
: this.$store.state.creation[2]
|
||||||
},
|
},
|
||||||
|
|||||||
@ -105,12 +105,12 @@
|
|||||||
"amount": "Betrag",
|
"amount": "Betrag",
|
||||||
"at": "am",
|
"at": "am",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
|
"change": "Ändern",
|
||||||
"check_now": "Jetzt prüfen",
|
"check_now": "Jetzt prüfen",
|
||||||
"close": "Schließen",
|
"close": "Schließen",
|
||||||
"current_balance": "Aktueller Kontostand",
|
"current_balance": "Aktueller Kontostand",
|
||||||
"date": "Datum",
|
"date": "Datum",
|
||||||
"description": "Beschreibung",
|
"description": "Beschreibung",
|
||||||
"edit": "Bearbeiten",
|
|
||||||
"email": "E-Mail",
|
"email": "E-Mail",
|
||||||
"firstname": "Vorname",
|
"firstname": "Vorname",
|
||||||
"from": "Von",
|
"from": "Von",
|
||||||
|
|||||||
@ -105,12 +105,12 @@
|
|||||||
"amount": "Amount",
|
"amount": "Amount",
|
||||||
"at": "at",
|
"at": "at",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"change": "Change",
|
||||||
"check_now": "Check now",
|
"check_now": "Check now",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"current_balance": "Current Balance",
|
"current_balance": "Current Balance",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"edit": "Edit",
|
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"firstname": "Firstname",
|
"firstname": "Firstname",
|
||||||
"from": "from",
|
"from": "from",
|
||||||
|
|||||||
@ -193,6 +193,13 @@ describe('Community', () => {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('set all data to the default values)', () => {
|
||||||
|
expect(wrapper.vm.form.id).toBe(null)
|
||||||
|
expect(wrapper.vm.form.date).toBe('')
|
||||||
|
expect(wrapper.vm.form.memo).toBe('')
|
||||||
|
expect(wrapper.vm.form.amount).toBe('')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with error', () => {
|
describe('with error', () => {
|
||||||
@ -273,6 +280,13 @@ describe('Community', () => {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('set all data to the default values)', () => {
|
||||||
|
expect(wrapper.vm.form.id).toBe(null)
|
||||||
|
expect(wrapper.vm.form.date).toBe('')
|
||||||
|
expect(wrapper.vm.form.memo).toBe('')
|
||||||
|
expect(wrapper.vm.form.amount).toBe('')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with error', () => {
|
describe('with error', () => {
|
||||||
@ -379,7 +393,7 @@ describe('Community', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the form date to the new values', () => {
|
it('sets the form data to the new values', () => {
|
||||||
expect(wrapper.vm.form.id).toBe(2)
|
expect(wrapper.vm.form.id).toBe(2)
|
||||||
expect(wrapper.vm.form.date).toBe(now)
|
expect(wrapper.vm.form.date).toBe(now)
|
||||||
expect(wrapper.vm.form.memo).toBe('Mein Beitrag zur Gemeinschaft für diesen Monat ...')
|
expect(wrapper.vm.form.memo).toBe('Mein Beitrag zur Gemeinschaft für diesen Monat ...')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user