Skip to content

Commit

Permalink
test: 💍 add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantasdeveloper committed Oct 24, 2024
1 parent 9634017 commit 706b27c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/api/procedures/__tests__/addInstruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1015,7 +1015,7 @@ describe('addInstruction procedure', () => {
null,
null,
[undefined],
rawPortfolioIds,
[rawFrom, rawTo],
null,
rawEmptyMediatorSet,
],
Expand Down
3 changes: 2 additions & 1 deletion src/api/procedures/__tests__/modifyInstructionAffirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ describe('modifyInstructionAffirmation procedure', () => {
.calledWith(rawAffirmationStatus)
.mockReturnValue(AffirmationStatus.Affirmed);

dsMockUtils.configureMocks({ contextOptions: { specVersion: 7000003 } });
const proc = procedureMockUtils.getInstance<
ModifyInstructionAffirmationParams,
Instruction,
Expand All @@ -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 }),
});
});
Expand Down
7 changes: 3 additions & 4 deletions src/base/__tests__/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
4 changes: 4 additions & 0 deletions src/testUtils/mocks/dataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ interface TxMockData {
interface ContextOptions {
did?: string;
isV6?: boolean;
specVersion?: number;
withSigningManager?: boolean;
balance?: AccountBalance;
subsidy?: SubsidyWithAllowance;
Expand Down Expand Up @@ -671,6 +672,7 @@ let queryMultiMock = jest.fn();
const defaultContextOptions: ContextOptions = {
did: 'someDid',
isV6: false,
specVersion: 7000004,
withSigningManager: true,
balance: {
free: new BigNumber(100),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -885,6 +888,7 @@ function configureContext(opts: ContextOptions): void {
const queryMock = mockInstanceContainer.apolloInstance.query;
const contextInstance = {
isV6,
specVersion,
signingAddress,
nonce,
getSigningIdentity,
Expand Down

0 comments on commit 706b27c

Please sign in to comment.