adapt community resolver unit tests to changes

This commit is contained in:
mahula 2023-04-07 15:59:50 +02:00
parent 9435c3620f
commit 3e277bcb79

View File

@ -36,6 +36,7 @@ describe('CommunityResolver', () => {
let foreignCom1: DbCommunity let foreignCom1: DbCommunity
let foreignCom2: DbCommunity let foreignCom2: DbCommunity
let foreignCom3: DbCommunity let foreignCom3: DbCommunity
describe('with empty list', () => { describe('with empty list', () => {
it('returns no community entry', async () => { it('returns no community entry', async () => {
// const result: Community[] = await query({ query: getCommunities }) // const result: Community[] = await query({ query: getCommunities })
@ -77,19 +78,19 @@ describe('CommunityResolver', () => {
await DbCommunity.insert(homeCom3) await DbCommunity.insert(homeCom3)
}) })
it('returns three home-community entries', async () => { it('returns 3 home-community entries', async () => {
await expect(query({ query: getCommunities })).resolves.toMatchObject({ await expect(query({ query: getCommunities })).resolves.toMatchObject({
data: { data: {
getCommunities: [ getCommunities: [
{ {
id: 1, id: 3,
foreign: homeCom1.foreign, foreign: homeCom3.foreign,
publicKey: expect.stringMatching('publicKey-HomeCommunity'), publicKey: expect.stringMatching('publicKey-HomeCommunity'),
url: expect.stringMatching('http://localhost/api/1_0'), url: expect.stringMatching('http://localhost/api/2_0'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: homeCom1.createdAt.toISOString(), createdAt: homeCom3.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
{ {
@ -104,14 +105,14 @@ describe('CommunityResolver', () => {
updatedAt: null, updatedAt: null,
}, },
{ {
id: 3, id: 1,
foreign: homeCom3.foreign, foreign: homeCom1.foreign,
publicKey: expect.stringMatching('publicKey-HomeCommunity'), publicKey: expect.stringMatching('publicKey-HomeCommunity'),
url: expect.stringMatching('http://localhost/api/2_0'), url: expect.stringMatching('http://localhost/api/1_0'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: homeCom3.createdAt.toISOString(), createdAt: homeCom1.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
], ],
@ -149,19 +150,19 @@ describe('CommunityResolver', () => {
await DbCommunity.insert(foreignCom3) await DbCommunity.insert(foreignCom3)
}) })
it('returns 3x home and 3x foreign-community entries', async () => { it('returns 3 home community and 3 foreign community entries', async () => {
await expect(query({ query: getCommunities })).resolves.toMatchObject({ await expect(query({ query: getCommunities })).resolves.toMatchObject({
data: { data: {
getCommunities: [ getCommunities: [
{ {
id: 1, id: 3,
foreign: homeCom1.foreign, foreign: homeCom3.foreign,
publicKey: expect.stringMatching('publicKey-HomeCommunity'), publicKey: expect.stringMatching('publicKey-HomeCommunity'),
url: expect.stringMatching('http://localhost/api/1_0'), url: expect.stringMatching('http://localhost/api/2_0'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: homeCom1.createdAt.toISOString(), createdAt: homeCom3.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
{ {
@ -176,25 +177,25 @@ describe('CommunityResolver', () => {
updatedAt: null, updatedAt: null,
}, },
{ {
id: 3, id: 1,
foreign: homeCom3.foreign, foreign: homeCom1.foreign,
publicKey: expect.stringMatching('publicKey-HomeCommunity'), publicKey: expect.stringMatching('publicKey-HomeCommunity'),
url: expect.stringMatching('http://localhost/api/2_0'), url: expect.stringMatching('http://localhost/api/1_0'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: homeCom3.createdAt.toISOString(), createdAt: homeCom1.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
{ {
id: 4, id: 6,
foreign: foreignCom1.foreign, foreign: foreignCom3.foreign,
publicKey: expect.stringMatching('publicKey-ForeignCommunity'), publicKey: expect.stringMatching('publicKey-ForeignCommunity'),
url: expect.stringMatching('http://remotehost/api/1_0'), url: expect.stringMatching('http://remotehost/api/1_2'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: foreignCom1.createdAt.toISOString(), createdAt: foreignCom3.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
{ {
@ -209,14 +210,14 @@ describe('CommunityResolver', () => {
updatedAt: null, updatedAt: null,
}, },
{ {
id: 6, id: 4,
foreign: foreignCom3.foreign, foreign: foreignCom1.foreign,
publicKey: expect.stringMatching('publicKey-ForeignCommunity'), publicKey: expect.stringMatching('publicKey-ForeignCommunity'),
url: expect.stringMatching('http://remotehost/api/1_2'), url: expect.stringMatching('http://remotehost/api/1_0'),
lastAnnouncedAt: null, lastAnnouncedAt: null,
verifiedAt: null, verifiedAt: null,
lastErrorAt: null, lastErrorAt: null,
createdAt: foreignCom3.createdAt.toISOString(), createdAt: foreignCom1.createdAt.toISOString(),
updatedAt: null, updatedAt: null,
}, },
], ],