Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🔨 Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Feb 7, 2024
1 parent 05cc4df commit cb22381
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion services/export/shared/helpers/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const getTokenBalancesAtGenesis = async () => {

// Asynchronously fetch the token module genesis assets and cache locally
logger.info('Attempting to fetch and cache the token module genesis assets.');
await requestConnector('getGenesisAssetsLength', {
requestConnector('getGenesisAssetsLength', {
module: MODULE.TOKEN,
subStore: MODULE_SUB_STORE.TOKEN.USER,
})
Expand Down
14 changes: 11 additions & 3 deletions services/export/tests/unit/shared/helpers/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
const { resolve } = require('path');

const delay = require('lisk-service-framework/src/delay');
const { valid, invalid } = require('../../../constants/account');
const { transactions } = require('../../../constants/transaction');

Expand Down Expand Up @@ -251,8 +252,15 @@ describe('Account utils', () => {

const { getTokenBalancesAtGenesis } = require('../../../../shared/helpers/account');

const tokenBalances = await getTokenBalancesAtGenesis();
const expectedResponse = [
const tokenBalances1 = await getTokenBalancesAtGenesis();
const expectedResponse1 = undefined;
expect(tokenBalances1).toEqual(expectedResponse1);

// Add delay to let the mock first resolve the async promise from requestConnector
await delay(10);

const tokenBalances2 = await getTokenBalancesAtGenesis();
const expectedResponse2 = [
{
tokenID: '0400000000000000',
address: 'lskyvvam5rxyvbvofxbdfcupxetzmqxu22phm4yuo',
Expand All @@ -261,7 +269,7 @@ describe('Account utils', () => {
},
];

expect(tokenBalances).toEqual(expectedResponse);
expect(tokenBalances2).toEqual(expectedResponse2);
});
});
});
15 changes: 2 additions & 13 deletions services/export/tests/unit/shared/helpers/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,13 @@ const { transactions } = require('../../../constants/transaction');

describe('Test Transaction utility', () => {
describe('Validate transaction amount is properly normalized', () => {
xit('should return amount in a standardized format for a valid transaction', async () => {
it('should return null amount for a non token:transfer and token:transferCrossChain transactions', async () => {
const amount = normalizeTransactionAmount(
transactions.reclaim.sender.address,
transactions.reclaim,
);

expect(amount).not.toBeNull();
expect(typeof amount).toBe('string');
expect(amount).toBe(transactions.reclaim.params.amount);
});

xit('should return positive amount value for reclaim transaction', async () => {
const amount = normalizeTransactionAmount(
transactions.reclaim.sender.address,
transactions.reclaim,
);

expect(Number(amount)).toBeGreaterThan(0);
expect(amount).toBeNull();
});

it('should return positive amount value for incoming token transfer transaction', async () => {
Expand Down

0 comments on commit cb22381

Please sign in to comment.