remove modal box if redeem a redeemlink

This commit is contained in:
ogerly 2022-09-16 08:22:24 +02:00
parent 9c7506f20c
commit e3e5fdd12b
3 changed files with 30 additions and 35 deletions

View File

@ -3,7 +3,7 @@
<redeem-information v-bind="linkData" :isContributionLink="isContributionLink" />
<b-jumbotron>
<div class="mb-3 text-center">
<b-button variant="primary" @click="$emit('redeem-link', linkData.amount)" size="lg">
<b-button variant="primary" @click="$emit('mutation-link', linkData.amount)" size="lg">
{{ $t('gdd_per_link.redeem') }}
</b-button>
</div>

View File

@ -282,18 +282,18 @@ describe('TransactionLink', () => {
})
describe('redeem link with success', () => {
let spy
// let spy
beforeEach(async () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
// spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
apolloMutateMock.mockResolvedValue()
spy.mockImplementation(() => Promise.resolve(true))
// spy.mockImplementation(() => Promise.resolve(true))
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
})
it('opens the modal', () => {
expect(spy).toBeCalledWith('gdd_per_link.redeem-text')
})
// it('opens the modal', () => {
// expect(spy).toBeCalledWith('gdd_per_link.redeem-text')
// })
it('calls the API', () => {
expect(apolloMutateMock).toBeCalledWith(
@ -316,37 +316,37 @@ describe('TransactionLink', () => {
})
})
describe('cancel redeem link', () => {
let spy
// describe('cancel redeem link', () => {
// let spy
beforeEach(async () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
apolloMutateMock.mockResolvedValue()
spy.mockImplementation(() => Promise.resolve(false))
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
})
// beforeEach(async () => {
// spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
// apolloMutateMock.mockResolvedValue()
// spy.mockImplementation(() => Promise.resolve(false))
// await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
// })
it('does not call the API', () => {
expect(apolloMutateMock).not.toBeCalled()
})
// it('does not call the API', () => {
// expect(apolloMutateMock).not.toBeCalled()
// })
it('does not toasts a success message', () => {
expect(mocks.$t).not.toBeCalledWith('gdd_per_link.redeemed', { n: '22' })
expect(toastSuccessSpy).not.toBeCalled()
})
// it('does not toasts a success message', () => {
// expect(mocks.$t).not.toBeCalledWith('gdd_per_link.redeemed', { n: '22' })
// expect(toastSuccessSpy).not.toBeCalled()
// })
it('does not push the route', () => {
expect(routerPushMock).not.toBeCalled()
})
})
// it('does not push the route', () => {
// expect(routerPushMock).not.toBeCalled()
// })
// })
describe('redeem link with error', () => {
let spy
// let spy
beforeEach(async () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
// spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
apolloMutateMock.mockRejectedValue({ message: 'Oh Noo!' })
spy.mockImplementation(() => Promise.resolve(true))
// spy.mockImplementation(() => Promise.resolve(true))
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
})

View File

@ -14,7 +14,7 @@
<redeem-valid
:linkData="linkData"
:isContributionLink="isContributionLink"
@redeem-link="redeemLink"
@mutation-link="mutationLink"
/>
</template>
@ -98,11 +98,6 @@ export default {
this.$router.push('/overview')
})
},
redeemLink(amount) {
this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.redeem-text')).then((value) => {
if (value) this.mutationLink(amount)
})
},
},
computed: {
isContributionLink() {