Forked from
Eclipse Projects / xfsc / Organization Credential Manager / OCM-Engine
336 commits behind the upstream repository.
-
Berend Sliedrecht authored
Signed-off-by:
Berend Sliedrecht <berend@animo.id>
Berend Sliedrecht authoredSigned-off-by:
Berend Sliedrecht <berend@animo.id>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
connections.e2e-spec.ts 1.91 KiB
import type { INestApplication } from '@nestjs/common';
import type { ClientProxy } from '@nestjs/microservices';
import type {
EventDidcommConnectionsGetById,
EventDidcommConnectionsGetAll,
} from '@ocm/shared';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import { firstValueFrom, type Observable } from 'rxjs';
import { AgentModule } from '../src/agent/agent.module.js';
import { ConnectionsModule } from '../src/agent/connections/connections.module.js';
import { mockConfigModule } from '../src/config/__tests__/mockConfig.js';
describe('Connections', () => {
const TOKEN = 'CONNECTIONS_CLIENT_SERVICE';
let app: INestApplication;
let client: ClientProxy;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [
mockConfigModule(3004),
AgentModule,
ConnectionsModule,
ClientsModule.register([{ name: TOKEN, transport: Transport.NATS }]),
],
}).compile();
app = moduleRef.createNestApplication();
app.connectMicroservice({ transport: Transport.NATS });
await app.startAllMicroservices();
await app.init();
client = app.get(TOKEN);
await client.connect();
});
it('didcomm.connections.getAll', async () => {
const response$: Observable<EventDidcommConnectionsGetAll> = client.send(
'didcomm.connections.getAll',
{},
);
const response = await firstValueFrom(response$);
expect(response.data).toMatchObject({ connections: [] });
});
it('didcomm.connections.getById', async () => {
const response$: Observable<EventDidcommConnectionsGetById> = client.send(
'didcomm.connections.getById',
{ id: 'some-id' },
);
const response = await firstValueFrom(response$);
expect(response.data).toMatchObject({ connection: null });
});
afterAll(async () => {
await app.close();
client.close();
});
});