mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
spec test for info page
This commit is contained in:
parent
45f877f559
commit
7fbdbb5217
@ -171,8 +171,6 @@ export const listContributionLinks = gql`
|
||||
amount
|
||||
name
|
||||
memo
|
||||
code
|
||||
link
|
||||
createdAt
|
||||
validFrom
|
||||
validTo
|
||||
|
||||
77
frontend/src/pages/InfoStatistic.spec.js
Normal file
77
frontend/src/pages/InfoStatistic.spec.js
Normal file
@ -0,0 +1,77 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import InfoStatistic from './InfoStatistic'
|
||||
import { toastErrorSpy } from '../../test/testSetup'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
listContributionLinks: {
|
||||
count: 2,
|
||||
links: [
|
||||
{
|
||||
id: 1,
|
||||
amount: 200,
|
||||
name: 'Dokumenta 2017',
|
||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2017',
|
||||
cycle: 'ONCE',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
amount: 200,
|
||||
name: 'Dokumenta 2022',
|
||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
||||
cycle: 'ONCE',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
describe('InfoStatistic', () => {
|
||||
let wrapper
|
||||
|
||||
const mocks = {
|
||||
$i18n: {
|
||||
locale: 'en',
|
||||
},
|
||||
$t: jest.fn((t) => t),
|
||||
$apollo: {
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(InfoStatistic, { localVue, mocks })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('renders the info page', () => {
|
||||
expect(wrapper.find('div.info-statistic').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('calls listUnconfirmedContributions', () => {
|
||||
expect(apolloQueryMock).toBeCalled()
|
||||
})
|
||||
|
||||
describe('error apolloQueryMock', () => {
|
||||
beforeEach(async () => {
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
message: 'uups',
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('toasts the error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith(
|
||||
'listContributionLinks has no result, use default data',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="info-statistic">
|
||||
<b-container>
|
||||
<div class="h3">{{ $t('community.community') }}</div>
|
||||
<div class="h1">{{ CONFIG.COMMUNITY_NAME }}</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user