mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test Info Page
This commit is contained in:
parent
35cb3176e3
commit
85e36a9cae
@ -1,32 +1,60 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import InfoStatistic from './InfoStatistic'
|
import InfoStatistic from './InfoStatistic'
|
||||||
import { toastErrorSpy } from '../../test/testSetup'
|
import { toastErrorSpy } from '../../test/testSetup'
|
||||||
|
import { listContributionLinks, communityStatistics, searchAdminUsers } from '@/graphql/queries'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
const apolloQueryMock = jest
|
||||||
data: {
|
.fn()
|
||||||
listContributionLinks: {
|
.mockResolvedValueOnce({
|
||||||
count: 2,
|
data: {
|
||||||
links: [
|
listContributionLinks: {
|
||||||
{
|
count: 2,
|
||||||
id: 1,
|
links: [
|
||||||
amount: 200,
|
{
|
||||||
name: 'Dokumenta 2017',
|
id: 1,
|
||||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2017',
|
amount: 200,
|
||||||
cycle: 'ONCE',
|
name: 'Dokumenta 2017',
|
||||||
},
|
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2017',
|
||||||
{
|
cycle: 'ONCE',
|
||||||
id: 2,
|
},
|
||||||
amount: 200,
|
{
|
||||||
name: 'Dokumenta 2022',
|
id: 2,
|
||||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
amount: 200,
|
||||||
cycle: 'ONCE',
|
name: 'Dokumenta 2022',
|
||||||
},
|
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
||||||
],
|
cycle: 'ONCE',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
.mockResolvedValueOnce({
|
||||||
|
data: {
|
||||||
|
searchAdminUsers: {
|
||||||
|
userCount: 2,
|
||||||
|
userList: [
|
||||||
|
{ firstName: 'Peter', lastName: 'Lustig' },
|
||||||
|
{ firstName: 'Super', lastName: 'Admin' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.mockResolvedValueOnce({
|
||||||
|
data: {
|
||||||
|
communityStatistics: {
|
||||||
|
totalUsers: 3113,
|
||||||
|
activeUsers: 1057,
|
||||||
|
deletedUsers: 35,
|
||||||
|
totalGradidoCreated: '4083774.05000000000000000000',
|
||||||
|
totalGradidoDecayed: '-1062639.13634129622923372197',
|
||||||
|
totalGradidoAvailable: '2513565.869444365732411569',
|
||||||
|
totalGradidoUnbookedDecayed: '-500474.6738366222166261272',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.mockResolvedValue('default')
|
||||||
|
|
||||||
describe('InfoStatistic', () => {
|
describe('InfoStatistic', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
@ -54,23 +82,48 @@ describe('InfoStatistic', () => {
|
|||||||
expect(wrapper.find('div.info-statistic').exists()).toBe(true)
|
expect(wrapper.find('div.info-statistic').exists()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls listUnconfirmedContributions', () => {
|
it('calls listContributionLinks', () => {
|
||||||
expect(apolloQueryMock).toBeCalled()
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
query: listContributionLinks,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls searchAdminUsers', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
query: searchAdminUsers,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls getCommunityStatistics', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
query: communityStatistics,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('error apolloQueryMock', () => {
|
describe('error apolloQueryMock', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
apolloQueryMock.mockRejectedValue({
|
apolloQueryMock.mockRejectedValue({
|
||||||
message: 'uups',
|
message: 'uups',
|
||||||
})
|
})
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
jest.clearAllMocks()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toasts the error message', () => {
|
it('toasts three error messages', () => {
|
||||||
expect(toastErrorSpy).toBeCalledWith(
|
expect(toastErrorSpy).toBeCalledWith(
|
||||||
'listContributionLinks has no result, use default data',
|
'listContributionLinks has no result, use default data',
|
||||||
)
|
)
|
||||||
|
expect(toastErrorSpy).toBeCalledWith('searchAdminUsers has no result, use default data')
|
||||||
|
expect(toastErrorSpy).toBeCalledWith('communityStatistics has no result, use default data')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -104,7 +104,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getContributionLinks() {
|
getContributionLinks() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.query({
|
||||||
query: listContributionLinks,
|
query: listContributionLinks,
|
||||||
@ -118,7 +118,7 @@ export default {
|
|||||||
this.toastError('listContributionLinks has no result, use default data')
|
this.toastError('listContributionLinks has no result, use default data')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async getAdminUsers() {
|
getAdminUsers() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.query({
|
||||||
query: searchAdminUsers,
|
query: searchAdminUsers,
|
||||||
@ -132,7 +132,7 @@ export default {
|
|||||||
this.toastError('searchAdminUsers has no result, use default data')
|
this.toastError('searchAdminUsers has no result, use default data')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async getCommunityStatistics() {
|
getCommunityStatistics() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.query({
|
||||||
query: communityStatistics,
|
query: communityStatistics,
|
||||||
@ -149,7 +149,7 @@ export default {
|
|||||||
result.data.communityStatistics.totalGradidoUnbookedDecayed
|
result.data.communityStatistics.totalGradidoUnbookedDecayed
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.toastError('listContributionLinks has no result, use default data')
|
this.toastError('communityStatistics has no result, use default data')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateTransactions(pagination) {
|
updateTransactions(pagination) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user