add test and increase coverage

This commit is contained in:
Claus-Peter Huebner 2023-08-18 17:31:39 +02:00
parent b18dd8e636
commit ed1ace5aab
2 changed files with 8 additions and 7 deletions

View File

@ -7,10 +7,10 @@ import { Field, ObjectType } from 'type-graphql'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class GetPublicCommunityInfoResult {
constructor(dbCom: DbCommunity) {
this.publicKey = dbCom.publicKey.toString('hex')
this.publicKey = dbCom.publicKey.toString()
this.name = dbCom.name
this.description = dbCom.description
this.createdAt = dbCom.creationDate
this.creationDate = dbCom.creationDate
}
@Field(() => String)
@ -20,7 +20,7 @@ export class GetPublicCommunityInfoResult {
description: string | null
@Field(() => Date)
createdAt: Date | null
creationDate: Date | null
@Field(() => String)
publicKey: string

View File

@ -30,20 +30,21 @@ describe('PublicCommunityInfoResolver', () => {
{
name
description
createdAt
creationDate
publicKey
}
}
`
describe('getPublicCommunityInfo', () => {
let homeCom: DbCommunity
beforeEach(async () => {
const homeCom = new DbCommunity()
homeCom = new DbCommunity()
homeCom.foreign = false
homeCom.url = 'homeCommunity-url'
homeCom.name = 'Community-Name'
homeCom.description = 'Community-Description'
homeCom.createdAt = new Date()
homeCom.creationDate = new Date()
homeCom.publicKey = Buffer.from('homeCommunity-publicKey')
await DbCommunity.insert(homeCom)
})
@ -54,7 +55,7 @@ describe('PublicCommunityInfoResolver', () => {
getPublicCommunityInfo: {
name: 'Community-Name',
description: 'Community-Description',
createdAt: expect.any(Date),
creationDate: homeCom.creationDate?.toISOString(),
publicKey: expect.stringMatching('homeCommunity-publicKey'),
},
},