From 33375c347ff69b2f8d7fe0a7d8ffce1fe19040ac Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 12:24:49 +0200 Subject: [PATCH] also test getPublicKey for 1.1 --- .../1_1/resolver/PublicKeyResolver.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts diff --git a/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts new file mode 100644 index 000000000..d41b53263 --- /dev/null +++ b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts @@ -0,0 +1,56 @@ +/* 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 { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity' +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_1' + +beforeAll(async () => { + const server = await createServer() + con = server.con + query = createTestClient(server.apollo).query + DbFederatedCommunity.clear() +}) + +afterAll(async () => { + await con.close() +}) + +describe('PublicKeyResolver', () => { + const getPublicKeyQuery = ` + query { + getPublicKey + { + publicKey + } + } + ` + + describe('getPublicKey', () => { + beforeEach(async () => { + const homeCom = new DbFederatedCommunity() + homeCom.foreign = false + homeCom.apiVersion = '1_0' + homeCom.endPoint = 'endpoint-url' + homeCom.publicKey = Buffer.from('homeCommunity-publicKey') + await DbFederatedCommunity.insert(homeCom) + }) + + it('returns homeCommunity-publicKey', async () => { + await expect(query({ query: getPublicKeyQuery })).resolves.toMatchObject({ + data: { + getPublicKey: { + publicKey: expect.stringMatching('homeCommunity-publicKey'), + }, + }, + }) + }) + }) +})