From 0ff1ae756276dc2acf44aca9b5faf866d2cfaf6d Mon Sep 17 00:00:00 2001 From: Shuffledex Date: Fri, 14 Feb 2020 13:33:52 -0300 Subject: [PATCH] fix: type coercion --- src/__tests__/Context.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/__tests__/Context.ts b/src/__tests__/Context.ts index 0d7baf69bc..eddc826f59 100644 --- a/src/__tests__/Context.ts +++ b/src/__tests__/Context.ts @@ -3,19 +3,18 @@ import { Context } from '~/Context'; import { ImportMock } from 'ts-mock-imports'; import * as polkadotModule from '@polymathnetwork/polkadot/api'; import * as identityModule from '~/api/entities/Identity'; +import { QueryableStorage } from '@polymathnetwork/polkadot/api/types'; -describe('Context Class', () => { +describe('Context class', () => { const mockKeyring = ImportMock.mockClass(polkadotModule, 'Keyring'); - const mockApiPromise = ImportMock.mockStaticClass( + const mockApiPromise = ImportMock.mockClass( polkadotModule, 'ApiPromise' ); - const mockIdentity = ImportMock.mockClass(identityModule, 'Identity'); afterAll(() => { mockKeyring.restore(); mockApiPromise.restore(); - mockIdentity.restore(); }); describe('method: create', () => { @@ -35,11 +34,11 @@ describe('Context Class', () => { }, }); const keyringAddFromSeedStub = mockKeyring.mock('addFromSeed', 'currentPair'); - mockApiPromise.set('query', { + mockApiPromise.set('query', ({ identity: { keyToIdentityIds: keyToIdentityIdsStub, }, - }); + } as unknown) as QueryableStorage<'promise'>); const context = await Context.create({ polymeshApi: mockApiPromise.getMockInstance(), @@ -55,11 +54,11 @@ describe('Context Class', () => { test('should create a Context class without Pair and Identity attached', async () => { const keyToIdentityIdsStub = sinon.stub().returns('identityId'); const keyringAddFromSeedMock = mockKeyring.mock('addFromSeed', true); - mockApiPromise.set('query', { + mockApiPromise.set('query', ({ identity: { keyToIdentityIds: keyToIdentityIdsStub, }, - }); + } as unknown) as QueryableStorage<'promise'>); const context = await Context.create({ polymeshApi: mockApiPromise.getMockInstance(), @@ -76,11 +75,11 @@ describe('Context Class', () => { unwrap: sinon.stub().throws(), }); mockKeyring.mock('addFromSeed', 'currentPair'); - mockApiPromise.set('query', { + mockApiPromise.set('query', ({ identity: { keyToIdentityIds: keyToIdentityIdsStub, }, - }); + } as unknown) as QueryableStorage<'promise'>); const context = Context.create({ polymeshApi: mockApiPromise.getMockInstance(),