From 706b27c245234b11a445883894cf46cdf130c45f Mon Sep 17 00:00:00 2001 From: Prashant Bajpai <34747455+prashantasdeveloper@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:00:45 +0530 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/procedures/__tests__/addInstruction.ts | 4 ++-- .../procedures/__tests__/modifyInstructionAffirmation.ts | 3 ++- src/base/__tests__/Context.ts | 7 +++---- src/testUtils/mocks/dataSources.ts | 4 ++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/api/procedures/__tests__/addInstruction.ts b/src/api/procedures/__tests__/addInstruction.ts index 3ea60ff387..c396b4b24c 100644 --- a/src/api/procedures/__tests__/addInstruction.ts +++ b/src/api/procedures/__tests__/addInstruction.ts @@ -985,7 +985,7 @@ describe('addInstruction procedure', () => { }); it('should handle NFT legs', async () => { - dsMockUtils.configureMocks({ contextOptions: { did: fromDid } }); + dsMockUtils.configureMocks({ contextOptions: { did: fromDid, specVersion: 7000003 } }); entityMockUtils.configureMocks({ venueOptions: { exists: true, @@ -1015,7 +1015,7 @@ describe('addInstruction procedure', () => { null, null, [undefined], - rawPortfolioIds, + [rawFrom, rawTo], null, rawEmptyMediatorSet, ], diff --git a/src/api/procedures/__tests__/modifyInstructionAffirmation.ts b/src/api/procedures/__tests__/modifyInstructionAffirmation.ts index 20e3b1c425..39d4f5d1c2 100644 --- a/src/api/procedures/__tests__/modifyInstructionAffirmation.ts +++ b/src/api/procedures/__tests__/modifyInstructionAffirmation.ts @@ -682,6 +682,7 @@ describe('modifyInstructionAffirmation procedure', () => { .calledWith(rawAffirmationStatus) .mockReturnValue(AffirmationStatus.Affirmed); + dsMockUtils.configureMocks({ contextOptions: { specVersion: 7000003 } }); const proc = procedureMockUtils.getInstance< ModifyInstructionAffirmationParams, Instruction, @@ -706,7 +707,7 @@ describe('modifyInstructionAffirmation procedure', () => { expect(result).toEqual({ transaction, feeMultiplier: new BigNumber(2), - args: [rawInstructionId, rawPortfolioIds, mockAffirmCount], + args: [rawInstructionId, [rawPortfolioId, rawPortfolioId], mockAffirmCount], resolver: expect.objectContaining({ id }), }); }); diff --git a/src/base/__tests__/Context.ts b/src/base/__tests__/Context.ts index e055fa1e56..3be9f835ec 100644 --- a/src/base/__tests__/Context.ts +++ b/src/base/__tests__/Context.ts @@ -83,10 +83,9 @@ describe('Context class', () => { beforeEach(() => { polymeshApi = dsMockUtils.getApiInstance(); - polymeshApi.query.asset = { - ...polymeshApi.query.asset, - tickerAssetId: expect.any(Function), - }; + dsMockUtils.setRuntimeVersion({ + specVersion: dsMockUtils.createMockU32(new BigNumber(7000004)), + }); dsMockUtils.setConstMock('system', 'ss58Prefix', { returnValue: dsMockUtils.createMockU8(new BigNumber(42)), diff --git a/src/testUtils/mocks/dataSources.ts b/src/testUtils/mocks/dataSources.ts index aa0077ef28..2abfa40412 100644 --- a/src/testUtils/mocks/dataSources.ts +++ b/src/testUtils/mocks/dataSources.ts @@ -431,6 +431,7 @@ interface TxMockData { interface ContextOptions { did?: string; isV6?: boolean; + specVersion?: number; withSigningManager?: boolean; balance?: AccountBalance; subsidy?: SubsidyWithAllowance; @@ -671,6 +672,7 @@ let queryMultiMock = jest.fn(); const defaultContextOptions: ContextOptions = { did: 'someDid', isV6: false, + specVersion: 7000004, withSigningManager: true, balance: { free: new BigNumber(100), @@ -815,6 +817,7 @@ let signingManagerOptions = defaultSigningManagerOptions; function configureContext(opts: ContextOptions): void { const getSigningIdentity = jest.fn(); const isV6 = opts.isV6; + const specVersion = opts.specVersion; const identity = { did: opts.did, hasRoles: jest.fn().mockResolvedValue(opts.hasRoles), @@ -885,6 +888,7 @@ function configureContext(opts: ContextOptions): void { const queryMock = mockInstanceContainer.apolloInstance.query; const contextInstance = { isV6, + specVersion, signingAddress, nonce, getSigningIdentity,