tests for ShowTransactionLinkInformations.vue

This commit is contained in:
ogerly 2022-03-18 19:13:36 +01:00
parent 0629909c9f
commit 302b2705ca

View File

@ -1,5 +1,8 @@
import { mount } from '@vue/test-utils'
import ShowTransactionLinkInformations from './ShowTransactionLinkInformations'
import { queryTransactionLink } from '@/graphql/queries'
import { redeemTransactionLink } from '@/graphql/mutations'
import { wrap } from 'regenerator-runtime'
const localVue = global.localVue
@ -7,8 +10,18 @@ const errorHandler = jest.fn()
localVue.config.errorHandler = errorHandler
const queryTransactionLink = jest.fn()
queryTransactionLink.mockResolvedValue('success')
const apolloQueryMock = jest.fn()
apolloQueryMock.mockResolvedValue({
id: 92,
amount: '22',
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
createdAt: '2022-03-17T16:10:28.000Z',
validUntil: '2022-03-31T16:10:28.000Z',
redeemedAt: '2022-03-18T10:08:43.000Z',
deletedAt: null,
user: { firstName: 'Bibi', publisherId: 0, email: 'bibi@bloxberg.de', __typename: 'User' },
__typename: 'TransactionLink',
})
const createMockObject = (code) => {
return {
@ -24,11 +37,11 @@ const createMockObject = (code) => {
},
},
$apollo: {
query: queryTransactionLink,
query: apolloQueryMock,
},
$route: {
params: {
code,
code: 'c0000c0000c0000',
},
},
},
@ -50,5 +63,18 @@ describe('ShowTransactionLinkInformations', () => {
it('renders the component', () => {
expect(wrapper.find('div.show-transaction-link-informations').exists()).toBeTruthy()
})
it('calls the queryTransactionLink query', () => {
expect(apolloQueryMock).toBeCalledWith({
query: queryTransactionLink,
variables: {
code: 'c0000c0000c0000',
},
})
})
it('has link one information link data', () => {
expect(apolloQueryMock.mockResolvedValue).toHaveLength(1)
})
})
})