diff --git a/tests/member-api.js b/tests/member-api.js index d11f8538a..e89c49209 100644 --- a/tests/member-api.js +++ b/tests/member-api.js @@ -4,10 +4,11 @@ import { KeyManager } from '@mapeo/crypto' import { MapeoRPC } from '../src/rpc/index.js' import { MemberApi } from '../src/member-api.js' +import { InviteResponse_Decision } from '../src/generated/rpc.js' import { replicate } from './helpers/rpc.js' test('Invite sends expected project-related details', async (t) => { - t.plan(3) + t.plan(4) const projectKey = KeyManager.generateProjectKeypair().publicKey const encryptionKeys = { auth: randomBytes(32) } @@ -23,16 +24,23 @@ test('Invite sends expected project-related details', async (t) => { rpc: r1, }) - r1.on('peers', (peers) => { - memberApi.invite(peers[0].id, { + r1.on('peers', async (peers) => { + const response = await memberApi.invite(peers[0].id, { role: 'member', }) + + t.is(response, InviteResponse_Decision.ACCEPT) }) - r2.on('invite', async (_peerId, invite) => { + r2.on('invite', async (peerId, invite) => { t.alike(invite.projectKey, projectKey) t.alike(invite.encryptionKeys, encryptionKeys) t.alike(invite.projectInfo, projectInfo) + + r2.inviteResponse(peerId, { + projectKey: invite.projectKey, + decision: InviteResponse_Decision.ACCEPT, + }) }) replicate(r1, r2)