fix tests

This commit is contained in:
Moriz Wahl 2022-06-17 13:58:46 +02:00
parent 6ecc10318d
commit 4475da0fbe
3 changed files with 21 additions and 19 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="redeem-self-creator"> <div class="redeem-self-creator">
<redeem-information :firstName="user.firstName" :amount="amount" :memo="memo" /> <redeem-information v-bind="linkData" :isContributionLink="isContributionLink" />
<b-jumbotron> <b-jumbotron>
<div class="mb-3 text-center"> <div class="mb-3 text-center">
@ -23,9 +23,8 @@ export default {
RedeemInformation, RedeemInformation,
}, },
props: { props: {
user: { type: Object, required: true }, linkData: { type: Object, required: true },
amount: { type: String, required: true }, isContributionLink: { type: Boolean, default: false },
memo: { type: String, required: true, default: '' },
}, },
} }
</script> </script>

View File

@ -24,6 +24,7 @@ const transactionLinkValidExpireDate = () => {
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -91,6 +92,7 @@ describe('TransactionLink', () => {
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -121,6 +123,7 @@ describe('TransactionLink', () => {
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -151,6 +154,7 @@ describe('TransactionLink', () => {
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -178,9 +182,11 @@ describe('TransactionLink', () => {
describe('no token in store', () => { describe('no token in store', () => {
beforeEach(() => { beforeEach(() => {
mocks.$store.state.token = null
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -211,14 +217,10 @@ describe('TransactionLink', () => {
describe('token in store and own link', () => { describe('token in store and own link', () => {
beforeEach(() => { beforeEach(() => {
mocks.$store.state.token = 'token' mocks.$store.state.token = 'token'
wrapper.setData({
linkData: {
user: { firstName: 'Bibi', publisherId: 0, email: 'bibi@bloxberg.de' },
},
})
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
@ -234,13 +236,12 @@ describe('TransactionLink', () => {
}) })
it('has a RedeemValid component', () => { it('has a RedeemValid component', () => {
// expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).exists()).toBe(true) expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).exists()).toBe(true)
expect(wrapper.findComponent({ name: 'RedeemValid' }).exists()).toBe(true)
}) })
it.skip('has a no redeem text', () => { it('has a no redeem text', () => {
expect(wrapper.findComponent({ name: 'RedeemValid' }).text()).toContain( expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).text()).toContain(
`Bibi transaction-link.send_you + 123.45 GDD memo· gdd_per_link.redeem`, 'gdd_per_link.no-redeem',
) )
}) })
@ -255,6 +256,7 @@ describe('TransactionLink', () => {
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
queryTransactionLink: { queryTransactionLink: {
__typename: 'TransactionLink',
id: 92, id: 92,
amount: '22', amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ', memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',

View File

@ -7,7 +7,7 @@
</template> </template>
<template #SELF_CREATOR> <template #SELF_CREATOR>
<redeem-self-creator v-bind="linkData" /> <redeem-self-creator :linkData="linkData" />
</template> </template>
<template #VALID> <template #VALID>
@ -47,6 +47,7 @@ export default {
return { return {
img: '/img/brand/green.png', img: '/img/brand/green.png',
linkData: { linkData: {
__typename: 'TransactionLink',
amount: '123.45', amount: '123.45',
memo: 'memo', memo: 'memo',
user: { user: {
@ -76,8 +77,8 @@ export default {
this.toastError(err.message) this.toastError(err.message)
}) })
}, },
async mutationLink(amount) { mutationLink(amount) {
await this.$apollo this.$apollo
.mutate({ .mutate({
mutation: redeemTransactionLink, mutation: redeemTransactionLink,
variables: { variables: {
@ -98,8 +99,8 @@ export default {
}) })
}, },
redeemLink(amount) { redeemLink(amount) {
this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.redeem-text')).then(async (value) => { this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.redeem-text')).then((value) => {
if (value) await this.mutationLink(amount) if (value) this.mutationLink(amount)
}) })
}, },
}, },