fix frontend tests

This commit is contained in:
einhorn_b 2023-08-30 18:00:26 +02:00
parent fef424b93d
commit 9a8fac54ae
3 changed files with 35 additions and 12 deletions

View File

@ -15,16 +15,12 @@
</template>
<script>
import { selectCommunities } from '@/graphql/queries'
import { COMMUNITY_NAME } from '@/config'
export default {
name: 'CommunitySwitch',
props: {
value: {
type: Object,
default: function () {
return { uuid: '', name: COMMUNITY_NAME }
},
},
},
data() {

View File

@ -4,7 +4,8 @@ import flushPromises from 'flush-promises'
import { SEND_TYPES } from '@/pages/Send'
import { createMockClient } from 'mock-apollo-client'
import VueApollo from 'vue-apollo'
import { user as userQuery } from '@/graphql/queries'
import { user as userQuery, selectCommunities as selectCommunitiesQuery } from '@/graphql/queries'
import { COMMUNITY_NAME } from '@/config'
const mockClient = createMockClient()
const apolloProvider = new VueApollo({
@ -61,6 +62,28 @@ describe('TransactionForm', () => {
}),
)
mockClient.setRequestHandler(
selectCommunitiesQuery,
jest.fn().mockResolvedValue({
data: {
communities: [
{
uuid: '8f4c146a-79b5-413f-89ed-53f624ec49b2',
name: 'Gradido Entwicklung',
description: 'Gradido-Community einer lokalen Entwicklungsumgebung.',
foreign: false,
},
{
uuid: 'ashasas',
name: 'Hunde-Community',
description: 'Hier geht es um Hunde',
foreign: true,
},
],
},
}),
)
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
@ -352,6 +375,12 @@ Die ganze Welt bezwingen.“`)
memo: 'Long enough',
selected: 'send',
userName: '',
targetCommunity: {
description: 'Gradido-Community einer lokalen Entwicklungsumgebung.',
foreign: false,
name: 'Gradido Entwicklung',
uuid: '8f4c146a-79b5-413f-89ed-53f624ec49b2',
},
},
],
])

View File

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import Send, { SEND_TYPES } from './Send'
import Send from './Send'
import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup'
import { TRANSACTION_STEPS } from '@/components/GddSend'
import { sendCoins, createTransactionLink } from '@/graphql/mutations.js'
@ -118,11 +118,10 @@ describe('Send', () => {
expect.objectContaining({
mutation: sendCoins,
variables: {
identifier: 'user@example.org',
recipientIdentifier: 'user@example.org',
amount: 23.45,
memo: 'Make the best of it!',
selected: SEND_TYPES.send,
userName: '',
recipientCommunityIdentifier: '',
},
}),
)
@ -217,11 +216,10 @@ describe('Send', () => {
expect.objectContaining({
mutation: sendCoins,
variables: {
identifier: 'gradido-ID',
recipientIdentifier: 'gradido-ID',
amount: 34.56,
memo: 'Make the best of it!',
selected: SEND_TYPES.send,
userName: '',
recipientCommunityIdentifier: '',
},
}),
)