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', () => {
it('reset enabled', () => {
expect(
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
describe('reset', () => {
it('enabled', () => {
expect(
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
})
})
it('submit enabled', () => {
expect(
wrapper.find('button[data-test="button-submit"]').attributes('disabled'),
).toBeFalsy()
describe('submit', () => {
it('enabled', () => {
expect(
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', () => {
it('reset enabled', () => {
expect(
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
describe('reset', () => {
it('enabled', () => {
expect(
wrapper.find('button[data-test="button-cancel"]').attributes('disabled'),
).toBeFalsy()
})
})
it('submit enabled', () => {
expect(
wrapper.find('button[data-test="button-submit"]').attributes('disabled'),
).toBeFalsy()
describe('submit', () => {
it('enabled', () => {
expect(
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: {
submit() {
// this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form) // is 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
// not working for testing:
// 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()
},
reset() {