Write new tests in 'ContributionForm.spec.js'

This commit is contained in:
Wolfgang Huß 2022-08-04 16:02:15 +02:00
parent f7dccb04b6
commit 9c8f76d080
2 changed files with 40 additions and 18 deletions

View File

@ -72,16 +72,26 @@ describe('ContributionForm', () => {
}) })
describe('has button', () => { describe('has button', () => {
it('reset enabled', () => { describe('reset', () => {
expect( it('enabled', () => {
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), expect(
).toBeFalsy() wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
})
}) })
it('submit enabled', () => { describe('submit', () => {
expect( it('enabled', () => {
wrapper.find('button[data-test="button-submit"]').attributes('disabled'), expect(
).toBeFalsy() wrapper.find('button[data-test="button-submit"]').attributes('disabled'),
).toBeFalsy()
})
it('labeled with "contribution.submit"', () => {
expect(wrapper.find('button[data-test="button-submit"]').text()).toContain(
'contribution.submit',
)
})
}) })
}) })
@ -131,16 +141,26 @@ describe('ContributionForm', () => {
}) })
describe('has button', () => { describe('has button', () => {
it('reset enabled', () => { describe('reset', () => {
expect( it('enabled', () => {
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), expect(
).toBeFalsy() wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
})
}) })
it('submit enabled', () => { describe('submit', () => {
expect( it('enabled', () => {
wrapper.find('button[data-test="button-submit"]').attributes('disabled'), expect(
).toBeFalsy() wrapper.find('button[data-test="button-submit"]').attributes('disabled'),
).toBeFalsy()
})
it('labeled with "form.change"', () => {
expect(wrapper.find('button[data-test="button-submit"]').text()).toContain(
'form.change',
)
})
}) })
}) })

View File

@ -98,8 +98,10 @@ export default {
}, },
methods: { methods: {
submit() { submit() {
// this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form) // is not working for testing // not working for testing:
this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form }) // this works for testing, why ever, we have to make a spread '...', to evaluate the values it looks like // this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form)
// works for testing, why ever, we have to make a spread '...', to evaluate the values it looks like: (I didn't find a solution in the test itmself)
this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form })
this.reset() this.reset()
}, },
reset() { reset() {