diff --git a/src/api/entities/TickerReservation/__tests__/index.ts b/src/api/entities/TickerReservation/__tests__/index.ts index df0257fcf9..ad34e080d2 100644 --- a/src/api/entities/TickerReservation/__tests__/index.ts +++ b/src/api/entities/TickerReservation/__tests__/index.ts @@ -30,7 +30,7 @@ describe('TickerReservation class', () => { }); describe('constructor', () => { - test('should assign ticker instance', () => { + test('should assign ticker to instance', () => { const ticker = 'abc'; const context = polkadotMockUtils.getContextInstance(); const tickerReservation = new TickerReservation({ ticker }, context); diff --git a/src/base/Namespace.ts b/src/base/Namespace.ts new file mode 100644 index 0000000000..2f322d9699 --- /dev/null +++ b/src/base/Namespace.ts @@ -0,0 +1,19 @@ +import { Entity } from '~/base'; +import { Context } from '~/context'; + +/** + * Represents a namespace within an Entity with the purpose of grouping related functionality + */ +export class Namespace> { + protected parent: Parent; + + protected context: Context; + + /** + * @hidden + */ + constructor(parent: Parent, context: Context) { + this.parent = parent; + this.context = context; + } +} diff --git a/src/base/__tests__/Entity.ts b/src/base/__tests__/Entity.ts index 28a2e8f72a..5591053372 100644 --- a/src/base/__tests__/Entity.ts +++ b/src/base/__tests__/Entity.ts @@ -1,23 +1,10 @@ import sinon from 'sinon'; -import { polkadotMockUtils } from '~/testUtils/mocks'; import * as utils from '~/utils'; import { Entity } from '../Entity'; describe('Entity class', () => { - beforeAll(() => { - polkadotMockUtils.initMocks(); - }); - - afterEach(() => { - polkadotMockUtils.reset(); - }); - - afterAll(() => { - polkadotMockUtils.cleanup(); - }); - describe('method: generateUuid', () => { test("should generate the Entity's UUID", async () => { sinon diff --git a/src/base/__tests__/Namespace.ts b/src/base/__tests__/Namespace.ts new file mode 100644 index 0000000000..75c0562188 --- /dev/null +++ b/src/base/__tests__/Namespace.ts @@ -0,0 +1,18 @@ +import { Entity } from '~/base'; +import { Namespace } from '~/base/Namespace'; +import { Context } from '~/context'; + +describe('Namespace class', () => { + describe('constructor', () => { + test('should assign parent and context to instance', () => { + const context = ('context' as unknown) as Context; + const parent = ('entity' as unknown) as Entity<{}>; + const namespace = new Namespace(parent, context); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + expect((namespace as any).parent).toEqual(parent); + expect((namespace as any).context).toEqual(context); + /* eslint-enable @typescript-eslint/no-explicit-any */ + }); + }); +}); diff --git a/src/base/index.ts b/src/base/index.ts index 4d70c32750..0ba2898e73 100644 --- a/src/base/index.ts +++ b/src/base/index.ts @@ -4,3 +4,4 @@ export { PolymeshError } from './PolymeshError'; export { TransactionQueue } from './TransactionQueue'; export { Procedure } from './Procedure'; export { Entity } from './Entity'; +export { Namespace } from './Namespace';