Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/xfsc/ocm/ocm-engine
  • zdravko61/ocm-engine
  • mjuergenscg/ocm-engine
  • tsabolov/ocm-engine
  • mikesell/ocm-engine
5 results
Show changes
Commits on Source (14)
Showing
with 820 additions and 7 deletions
......@@ -31,10 +31,9 @@ export default {
: ['text-summary', 'html'],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/test/',
'<rootDir>/coverage/',
'<rootDir>/dist/',
'<rootDir>/**/test',
'__tests__',
'@types',
'.dto.(t|j)s',
'.enum.ts',
......
......@@ -32,6 +32,7 @@
"@nestjs/platform-express": "^10.2.8",
"@nestjs/swagger": "^7.1.16",
"@nestjs/terminus": "^10.1.1",
"@ocm/shared": "workspace:*",
"axios": "^1.6.2",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
......
import type { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Application } from '../application.js';
describe('Application', () => {
let app: INestApplication;
beforeAll(async () => {
const moduleFixture = await Test.createTestingModule({
imports: [Application],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
afterAll(async () => {
await app.close();
});
it('should be defined', () => {
expect(app).toBeDefined();
});
});
import type { ConfigType } from '@nestjs/config';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { NATS_CLIENT } from './common/constants.js';
import { httpConfig } from './config/http.config.js';
import { natsConfig } from './config/nats.config.js';
import { ssiConfig } from './config/ssi.config.js';
import { validationSchema } from './config/validation.js';
import { HealthModule } from './health/health.module.js';
import { SchemasModule } from './schemas/schemas.module.js';
@Module({
imports: [
......@@ -20,7 +25,25 @@ import { HealthModule } from './health/health.module.js';
abortEarly: true,
},
}),
ClientsModule.registerAsync({
isGlobal: true,
clients: [
{
name: NATS_CLIENT,
inject: [natsConfig.KEY],
useFactory: (config: ConfigType<typeof natsConfig>) => ({
transport: Transport.NATS,
options: {
url: config.url as string,
},
}),
},
],
}),
HealthModule,
SchemasModule,
],
})
export default class AppModule {}
export class Application {}
export const SERVICE_NAME = 'SCHEMA_MANAGER_SERVICE';
export const NATS_CLIENT = Symbol('NATS_CLIENT');
/* c8 ignore start */
import type { MicroserviceOptions } from '@nestjs/microservices';
import { VersioningType } from '@nestjs/common';
......@@ -6,9 +7,9 @@ import { NestFactory } from '@nestjs/core';
import { Transport } from '@nestjs/microservices';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import AppModule from './app.module.js';
import { Application } from './application.js';
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(Application);
const configService = app.get(ConfigService);
app.enableCors();
......@@ -36,3 +37,4 @@ SwaggerModule.setup('/swagger', app, document);
await app.startAllMicroservices();
await app.listen(configService.get('PORT') || 3000);
/* c8 ignore stop */
import type { RegisterSchemaPayload } from '../dto/register-schema.dto.js';
import type { TestingModule } from '@nestjs/testing';
import type {
EventAnonCredsSchemasGetAll,
EventAnonCredsSchemasGetById,
EventAnonCredsSchemasRegister,
} from '@ocm/shared';
import { Test } from '@nestjs/testing';
import { Subject, of, takeUntil } from 'rxjs';
import { NATS_CLIENT } from '../../common/constants.js';
import { SchemasController } from '../schemas.controller.js';
import { SchemasService } from '../schemas.service.js';
describe('SchemasController', () => {
const natsClientMock = {};
let controller: SchemasController;
let service: SchemasService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [SchemasController],
providers: [
{ provide: NATS_CLIENT, useValue: natsClientMock },
SchemasService,
],
}).compile();
controller = module.get<SchemasController>(SchemasController);
service = module.get<SchemasService>(SchemasService);
});
describe('getAll', () => {
it('should return a list of schemas', (done) => {
const unsubscribe$ = new Subject<void>();
const tenantId = 'exampleTenantId';
const expectedResult: EventAnonCredsSchemasGetAll['data'] = [];
jest.spyOn(service, 'getAll').mockReturnValue(of(expectedResult));
controller
.getAll({ tenantId })
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
});
describe('getById', () => {
it('should return a schema by id', (done) => {
const unsubscribe$ = new Subject<void>();
const schemaId = 'exampleSchemaId';
const tenantId = 'exampleTenantId';
const expectedResult: EventAnonCredsSchemasGetById['data'] = {
attrNames: ['exampleAttributeName'],
issuerId: 'exampleIssuerDid',
name: 'exampleName',
version: '1.0.0',
};
jest.spyOn(service, 'getById').mockReturnValue(of(expectedResult));
controller
.getById({ schemaId }, { tenantId })
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
it('should throw a NotFoundException if the service returned null', (done) => {
const unsubscribe$ = new Subject<void>();
const schemaId = 'exampleSchemaId';
const tenantId = 'exampleTenantId';
jest.spyOn(service, 'getById').mockReturnValue(of(null));
controller
.getById({ schemaId }, { tenantId })
.pipe(takeUntil(unsubscribe$))
.subscribe({
error: (error) => {
expect(error.status).toBe(404);
expect(error.message).toBe(`Schema with id ${schemaId} not found`);
unsubscribe$.next();
unsubscribe$.complete();
done();
},
});
});
});
describe('register', () => {
it('should register a new schema', (done) => {
const unsubscribe$ = new Subject<void>();
const tenantId = 'exampleTenantId';
const payload: RegisterSchemaPayload = {
attributeNames: ['exampleAttributeName'],
issuerDid: 'exampleIssuerDid',
name: 'exampleName',
version: '1.0.0',
};
const expectedResult: EventAnonCredsSchemasRegister['data'] = {
attrNames: payload.attributeNames,
issuerId: payload.issuerDid,
name: payload.name,
version: payload.version,
};
jest.spyOn(service, 'register').mockReturnValue(of(expectedResult));
controller
.register({ tenantId }, payload)
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
});
});
import { ClientsModule } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import { NATS_CLIENT } from '../../common/constants.js';
import { SchemasController } from '../schemas.controller.js';
import { SchemasModule } from '../schemas.module.js';
import { SchemasService } from '../schemas.service.js';
describe('Schemas Module', () => {
let schemasController: SchemasController;
let schemasService: SchemasService;
beforeEach(async () => {
const moduleRef = await Test.createTestingModule({
imports: [
ClientsModule.registerAsync({
isGlobal: true,
clients: [{ name: NATS_CLIENT, useFactory: () => ({}) }],
}),
SchemasModule,
],
}).compile();
schemasController = moduleRef.get<SchemasController>(SchemasController);
schemasService = moduleRef.get<SchemasService>(SchemasService);
});
it('should be defined', () => {
expect(schemasController).toBeDefined();
expect(schemasController).toBeInstanceOf(SchemasController);
expect(schemasService).toBeDefined();
expect(schemasService).toBeInstanceOf(SchemasService);
});
});
import type { TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import {
EventAnonCredsSchemasGetAll,
EventAnonCredsSchemasGetById,
EventAnonCredsSchemasRegister,
} from '@ocm/shared';
import { Subject, of, takeUntil } from 'rxjs';
import { NATS_CLIENT } from '../../common/constants.js';
import { SchemasService } from '../schemas.service.js';
describe('SchemasService', () => {
let service: SchemasService;
const natsClientMock = { send: jest.fn() };
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
{ provide: NATS_CLIENT, useValue: natsClientMock },
SchemasService,
],
}).compile();
service = module.get<SchemasService>(SchemasService);
jest.resetAllMocks();
});
describe('getAll', () => {
it('should return the data from NATS client', (done) => {
const unsubscribe$ = new Subject<void>();
const payload = {
tenantId: 'mocked tenantId',
endpoint: EventAnonCredsSchemasGetAll.token,
};
const expectedResult: EventAnonCredsSchemasGetAll['data'] = [];
natsClientMock.send.mockReturnValueOnce(
of(new EventAnonCredsSchemasGetAll([], payload.tenantId)),
);
service
.getAll(payload)
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(natsClientMock.send).toHaveBeenCalledWith(
{ endpoint: EventAnonCredsSchemasGetAll.token },
payload,
);
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
});
describe('getById', () => {
it('should return the data from NATS client', (done) => {
const unsubscribe$ = new Subject<void>();
const payload = {
tenantId: 'mocked tenantId',
schemaId: 'mocked id',
};
const expectedResult: EventAnonCredsSchemasGetById['data'] = {
issuerId: 'mocked issuerDid',
name: 'mocked name',
version: '1.0.0',
attrNames: ['mocked attribute1', 'mocked attribute2'],
};
natsClientMock.send.mockReturnValueOnce(
of(new EventAnonCredsSchemasGetById(expectedResult, payload.tenantId)),
);
service
.getById(payload)
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(natsClientMock.send).toHaveBeenCalledWith(
{ endpoint: EventAnonCredsSchemasGetById.token },
payload,
);
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
});
describe('register', () => {
it('should return the data from NATS client', (done) => {
const unsubscribe$ = new Subject<void>();
const payload = {
tenantId: 'mocked tenantId',
issuerDid: 'mocked issuerDid',
name: 'mocked name',
version: '1.0.0',
attributeNames: ['mocked attribute1', 'mocked attribute2'],
};
const expectedResult: EventAnonCredsSchemasRegister['data'] = {
issuerId: 'mocked issuerDid',
name: 'mocked name',
version: '1.0.0',
attrNames: ['mocked attribute1', 'mocked attribute2'],
};
natsClientMock.send.mockReturnValueOnce(
of(new EventAnonCredsSchemasRegister(expectedResult, payload.tenantId)),
);
service
.register(payload)
.pipe(takeUntil(unsubscribe$))
.subscribe((result) => {
expect(natsClientMock.send).toHaveBeenCalledWith(
{ endpoint: EventAnonCredsSchemasRegister.token },
payload,
);
expect(result).toStrictEqual(expectedResult);
unsubscribe$.next();
unsubscribe$.complete();
done();
});
});
});
});
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString } from 'class-validator';
export class GetByIdParams {
@IsString()
@IsNotEmpty()
@ApiProperty({ description: 'The schema ID to retrieve', format: 'string' })
public schemaId: string;
}
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsNotEmpty, IsSemVer, IsString } from 'class-validator';
export class RegisterSchemaPayload {
@IsString()
@IsNotEmpty()
@ApiProperty()
public issuerDid: string;
@IsString()
@IsNotEmpty()
@ApiProperty()
public name: string;
@IsString()
@IsNotEmpty()
@IsSemVer()
@ApiProperty()
public version: string;
@IsArray()
@IsString({ each: true })
@IsNotEmpty({ each: true })
@ApiProperty()
public attributeNames: Array<string>;
}
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString } from 'class-validator';
export class TenantIdParam {
@IsString()
@IsNotEmpty()
@ApiProperty({
description: 'The tenant ID to use for the request',
format: 'string',
})
public tenantId: string;
}
import type {
EventAnonCredsSchemasGetAll,
EventAnonCredsSchemasGetById,
EventAnonCredsSchemasRegister,
} from '@ocm/shared';
import {
Body,
Controller,
Get,
HttpStatus,
NotFoundException,
Param,
Post,
Query,
UsePipes,
ValidationPipe,
Version,
} from '@nestjs/common';
import {
ApiBody,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { Observable, of, switchMap } from 'rxjs';
import { GetByIdParams } from './dto/get-by-id.dto.js';
import { RegisterSchemaPayload } from './dto/register-schema.dto.js';
import { TenantIdParam } from './dto/tenant-id.dto.js';
import { SchemasService } from './schemas.service.js';
@Controller('schemas')
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
@ApiTags('Schemas')
export class SchemasController {
public constructor(private readonly schemasService: SchemasService) {}
@Version('1')
@Get()
@ApiOperation({
summary: 'Fetch a list of schemas',
description: 'This call provides a list of schemas for a given tenant',
})
@ApiQuery({ name: 'tenantId', required: true })
@ApiResponse({
status: HttpStatus.OK,
description: 'Schemas fetched successfully',
content: {
// TBD
},
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Tenant not found',
content: {
// TBD
},
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error',
content: {
// TBD
},
})
public getAll(
@Query() { tenantId }: TenantIdParam,
): Observable<EventAnonCredsSchemasGetAll['data']> {
return this.schemasService.getAll({
tenantId,
});
}
@Version('1')
@Get(':schemaId')
@ApiOperation({
summary: 'Fetch a schema by id',
description:
'This call allows you to retrieve schema data for a given tenant by specifying the `schemaId`.',
})
@ApiParam({ name: 'schemaId', required: true })
@ApiQuery({ name: 'tenantId', required: true })
@ApiResponse({
status: HttpStatus.OK,
description: 'Schema fetched successfully',
content: {
// TBD
},
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Tenant not found',
content: {
// TBD
},
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Schema not found',
content: {
// TBD
},
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error',
content: {
// TBD
},
})
public getById(
@Param() { schemaId }: GetByIdParams,
@Query() { tenantId }: TenantIdParam,
): Observable<EventAnonCredsSchemasGetById['data']> {
return this.schemasService
.getById({
tenantId,
schemaId,
})
.pipe(
switchMap((schema) => {
if (schema === null) {
throw new NotFoundException(`Schema with id ${schemaId} not found`);
}
return of(schema);
}),
);
}
@Version('1')
@Post()
@ApiOperation({
summary: 'Register a new schema',
description:
'This call provides the capability to create new schema on ledger by name, author, version, schema attributes and type. Later this schema can be used to issue new credential definition. This call returns an information about created schema.',
})
@ApiQuery({ name: 'tenantId', required: true })
@ApiBody({ type: RegisterSchemaPayload })
@ApiResponse({
status: HttpStatus.CREATED,
description: 'Schema registered successfully',
content: {
'application/json': {},
},
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Tenant not found',
content: {
'application/json': {},
},
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description: 'All fields are required for schema registration',
content: {
'application/json': {},
},
})
@ApiResponse({
status: HttpStatus.CONFLICT,
description: 'Schema already exists',
content: {
'application/json': {},
},
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error',
content: {
'application/json': {},
},
})
public register(
@Query() { tenantId }: TenantIdParam,
@Body() payload: RegisterSchemaPayload,
): Observable<EventAnonCredsSchemasRegister['data']> {
return this.schemasService.register({
...payload,
tenantId,
});
}
}
import { Module } from '@nestjs/common';
import { SchemasController } from './schemas.controller.js';
import { SchemasService } from './schemas.service.js';
@Module({
controllers: [SchemasController],
providers: [SchemasService],
})
export class SchemasModule {}
import type {
EventAnonCredsSchemasGetAllInput,
EventAnonCredsSchemasGetByIdInput,
EventAnonCredsSchemasRegisterInput,
} from '@ocm/shared';
import { Inject, Injectable } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import {
EventAnonCredsSchemasGetAll,
EventAnonCredsSchemasGetById,
EventAnonCredsSchemasRegister,
} from '@ocm/shared';
import { map, type Observable } from 'rxjs';
import { NATS_CLIENT } from '../common/constants.js';
@Injectable()
export class SchemasService {
public constructor(
@Inject(NATS_CLIENT) private readonly natsClient: ClientProxy,
) {}
public getAll(
payload: EventAnonCredsSchemasGetAllInput,
): Observable<EventAnonCredsSchemasGetAll['data']> {
const pattern = { endpoint: EventAnonCredsSchemasGetAll.token };
return this.natsClient
.send<EventAnonCredsSchemasGetAll, EventAnonCredsSchemasGetAllInput>(
pattern,
payload,
)
.pipe(map((result) => result.data));
}
public getById(
payload: EventAnonCredsSchemasGetByIdInput,
): Observable<EventAnonCredsSchemasGetById['data']> {
const pattern = { endpoint: EventAnonCredsSchemasGetById.token };
return this.natsClient
.send<EventAnonCredsSchemasGetById, EventAnonCredsSchemasGetByIdInput>(
pattern,
payload,
)
.pipe(map((result) => result.data));
}
public register(
payload: EventAnonCredsSchemasRegisterInput,
): Observable<EventAnonCredsSchemasRegister['data']> {
const pattern = { endpoint: EventAnonCredsSchemasRegister.token };
return this.natsClient
.send<EventAnonCredsSchemasRegister, EventAnonCredsSchemasRegisterInput>(
pattern,
payload,
)
.pipe(map((result) => result.data));
}
}
......@@ -22,6 +22,7 @@
},
"dependencies": {
"@aries-framework/core": "0.4.2",
"@aries-framework/tenants": "^0.4.2",
"@elastic/ecs-winston-format": "^1.5.0",
"@nestjs/common": "^10.2.10",
"@nestjs/microservices": "^10.2.10",
......@@ -32,10 +33,10 @@
"winston": "^3.11.0"
},
"devDependencies": {
"@types/jest": "^29.5.9",
"@types/node": "^20.9.3",
"@nestjs/cli": "^10.2.1",
"@nestjs/testing": "^10.2.10",
"@types/jest": "^29.5.9",
"@types/node": "^20.9.3",
"rimraf": "^5.0.5",
"supertest": "^6.1.3",
"ts-jest": "^29.1.1",
......
import { BaseEvent, EventDidcommConnectionsGetAll } from './events.js';
import { BaseEvent } from '../baseEvents.js';
describe('check logger', () => {
describe('Base Events', () => {
it('should return module', () => {
jest.requireActual('./events');
jest.requireActual('../baseEvents');
});
it('should create a new base event', () => {
const baseEvent = new BaseEvent({ some: 'data' });
const baseEvent = new BaseEvent({ some: 'data' }, 'tenantId');
expect(typeof baseEvent.id).toStrictEqual('string');
expect(baseEvent.type).toStrictEqual('BaseEvent');
expect(baseEvent.timestamp).toBeInstanceOf(Date);
expect(baseEvent.data).toMatchObject({ some: 'data' });
});
it('should create a new connections get all event', () => {
const getAllConnectionsEvent = new EventDidcommConnectionsGetAll({
connections: [],
});
expect(typeof getAllConnectionsEvent.id).toStrictEqual('string');
expect(getAllConnectionsEvent.type).toStrictEqual(
'EventDidcommConnectionsGetAll',
);
expect(getAllConnectionsEvent.timestamp).toBeInstanceOf(Date);
expect(getAllConnectionsEvent.data).toMatchObject({ connections: [] });
});
});
import {
ConnectionRecord,
DidExchangeRole,
DidExchangeState,
} from '@aries-framework/core';
import {
EventDidcommConnectionsBlock,
EventDidcommConnectionsCreateWithSelf,
EventDidcommConnectionsGetAll,
EventDidcommConnectionsGetById,
} from '../connectionEvents.js';
describe('Connection Events', () => {
it('should return module', () => {
jest.requireActual('../connectionEvents');
});
it('should create a new connections get all event', () => {
const event = new EventDidcommConnectionsGetAll([], 'tenantId');
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidcommConnectionsGetAll');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject([]);
});
it('should create a new connections get by id event', () => {
const event = new EventDidcommConnectionsGetById(null, 'tenantId');
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidcommConnectionsGetById');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toBeNull();
});
it('should create a new connections create with self event', () => {
const event = new EventDidcommConnectionsCreateWithSelf(
new ConnectionRecord({
role: DidExchangeRole.Requester,
state: DidExchangeState.Completed,
}),
'tenantId',
);
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidcommConnectionsCreateWithSelf');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject({
role: DidExchangeRole.Requester,
state: DidExchangeState.Completed,
});
});
it('should create a new connections block event', () => {
const event = new EventDidcommConnectionsBlock(
new ConnectionRecord({
role: DidExchangeRole.Requester,
state: DidExchangeState.Completed,
}),
'tenantId',
);
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidcommConnectionsBlock');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject({
role: DidExchangeRole.Requester,
state: DidExchangeState.Completed,
});
});
});
import { DidDocument } from '@aries-framework/core';
import { EventDidsPublicDid, EventDidsResolve } from '../didEvents.js';
describe('Did Events', () => {
it('should return module', () => {
jest.requireActual('../didEvents');
});
it('should create get public did event', () => {
const doc = new DidDocument({ id: 'did:web:123.com' });
const event = new EventDidsPublicDid(doc, 'tenantId');
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidsPublicDid');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject(doc);
});
it('should create did resolve event', () => {
const doc = new DidDocument({ id: 'did:my:id' });
const event = new EventDidsResolve(doc, 'tenantId');
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventDidsResolve');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject(doc);
});
});
import { TenantRecord } from '@aries-framework/tenants';
import { EventTenantsCreate } from '../tenantEvents.js';
describe('Tenant Events', () => {
it('should return module', () => {
jest.requireActual('../tenantEvents');
});
it('should create a create tenant event', () => {
const tenantRecord = new TenantRecord({
config: {
label: 'my-label',
walletConfig: { id: 'some-id', key: 'some-key' },
},
});
const event = new EventTenantsCreate(tenantRecord, undefined);
expect(typeof event.id).toStrictEqual('string');
expect(event.type).toStrictEqual('EventTenantsCreate');
expect(event.timestamp).toBeInstanceOf(Date);
expect(event.instance).toMatchObject(tenantRecord);
});
});