From 46831167bc905345283bfd0807a81c2d2744a893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Mar 2023 01:14:18 +0100 Subject: [PATCH] new testclass --- .../1_0/resolver/PublicKeyResolver.test.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts diff --git a/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts new file mode 100644 index 000000000..1622c7be4 --- /dev/null +++ b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts @@ -0,0 +1,54 @@ +/* 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' + +let query: any +let testEnv: any + +// to do: We need a setup for the tests that closes the connection +let con: any + +beforeAll(async () => { + const server = await createServer() + con = server.con + query = createTestClient(server.apollo).query + DbCommunity.clear() +}) + +afterAll(async () => { + await con.close() +}) + +describe('PublicKeyResolver', () => { + const getPublicKeyQuery = ` + query { + getPublicKey + { + publicKey + } + } + ` + + describe('getPublicKey', () => { + beforeEach(async () => { + const homeCom = new DbCommunity() + homeCom.foreign = false + homeCom.apiVersion = '1_0' + homeCom.endPoint = 'endpoint-url' + homeCom.publicKey = Buffer.from('homeCommunity-publicKey') + await DbCommunity.insert(homeCom) + }) + + it('returns homeCommunity-publicKey', async () => { + await expect(query({ query: getPublicKeyQuery })).resolves.toMatchObject({ + data: { + getPublicKey: { + publicKey: 'homeCommunity-publicKey', + }, + }, + }) + }) + }) +})