mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
additional Tests
This commit is contained in:
parent
986ac2c998
commit
b18dd8e636
@ -0,0 +1,64 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { createTestClient } from 'apollo-server-testing'
|
||||
import createServer from '@/server/createServer'
|
||||
import { Community as DbCommunity } from '@entity/Community'
|
||||
import CONFIG from '@/config'
|
||||
|
||||
let query: any
|
||||
|
||||
// to do: We need a setup for the tests that closes the connection
|
||||
let con: any
|
||||
|
||||
CONFIG.FEDERATION_API = '1_0'
|
||||
|
||||
beforeAll(async () => {
|
||||
const server = await createServer()
|
||||
con = server.con
|
||||
query = createTestClient(server.apollo).query
|
||||
DbCommunity.clear()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await con.close()
|
||||
})
|
||||
|
||||
describe('PublicCommunityInfoResolver', () => {
|
||||
const getPublicCommunityInfoQuery = `
|
||||
query {
|
||||
getPublicCommunityInfo
|
||||
{
|
||||
name
|
||||
description
|
||||
createdAt
|
||||
publicKey
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
describe('getPublicCommunityInfo', () => {
|
||||
beforeEach(async () => {
|
||||
const homeCom = new DbCommunity()
|
||||
homeCom.foreign = false
|
||||
homeCom.url = 'homeCommunity-url'
|
||||
homeCom.name = 'Community-Name'
|
||||
homeCom.description = 'Community-Description'
|
||||
homeCom.createdAt = new Date()
|
||||
homeCom.publicKey = Buffer.from('homeCommunity-publicKey')
|
||||
await DbCommunity.insert(homeCom)
|
||||
})
|
||||
|
||||
it('returns public CommunityInfo', async () => {
|
||||
await expect(query({ query: getPublicCommunityInfoQuery })).resolves.toMatchObject({
|
||||
data: {
|
||||
getPublicCommunityInfo: {
|
||||
name: 'Community-Name',
|
||||
description: 'Community-Description',
|
||||
createdAt: expect.any(Date),
|
||||
publicKey: expect.stringMatching('homeCommunity-publicKey'),
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -10,13 +10,9 @@ export class PublicCommunityInfoResolver {
|
||||
@Query(() => GetPublicCommunityInfoResult)
|
||||
async getPublicCommunityInfo(): Promise<GetPublicCommunityInfoResult> {
|
||||
logger.debug(`getPublicCommunityInfo() via apiVersion=1_0 ...`)
|
||||
const homeCom = await DbCommunity.findOneOrFail({ foreign: false })
|
||||
const homeCom = await DbCommunity.findOneByOrFail({ foreign: false })
|
||||
const result = new GetPublicCommunityInfoResult(homeCom)
|
||||
logger.info(
|
||||
`getPublicCommunityInfo()-1_0... return publicInfo=${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
)
|
||||
logger.info(`getPublicCommunityInfo()-1_0... return publicInfo=${JSON.stringify(result)}`)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user