Skip to content

Commit

Permalink
test: updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Aug 27, 2024
1 parent 9ca69ce commit bba4959
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jest.mock('common-util/Details/utils', () => ({
checkIfServiceRequiresWhitelisting: jest.fn(() => false),
}));

jest.mock('common-util/Details/DetailsSubInfo/hooks', () => ({
useTokenomicsUnitType: jest.fn(() => 1),
}));

jest.mock('common-util/hooks/useHelpers', () => ({
useHelpers: () => useHelpersEvmMock,
}));
Expand All @@ -66,6 +70,7 @@ jest.mock('components/ListAgents/utils', () => ({
getAgentHashes: jest.fn(),
getAgentOwner: jest.fn(),
getTokenUri: jest.fn(),
updateAgentHashes: jest.fn(),
}));

const dummyDetails = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jest.mock('../../../common-util/Contracts', () => ({
getAgentContract: jest.fn(),
}));

// TODO: mock updateAgentHashes instead
jest.mock('libs/util-constants/src', () => ({
TOKENOMICS_UNIT_TYPES: { COMPONENT: '0', AGENT: '1' },
}));

describe('listAgents/utils.jsx', () => {
it('getFilteredAgents: Promise resolved', async () => {
getAgentContract.mockImplementation(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jest.mock('components/ListComponents/utils', () => ({
getTokenUri: jest.fn(),
}));

jest.mock('common-util/Details/DetailsSubInfo/hooks', () => ({
useTokenomicsUnitType: jest.fn(() => 1),
}));

const dummyDetails = {
owner: dummyAddress,
developer: dummyAddress,
Expand Down Expand Up @@ -123,7 +127,6 @@ describe('listComponents/details.jsx', () => {
});
});


it('should display rewards section', async () => {
const { getByText } = render(wrapProvider(<Component />));
await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jest.mock('../../../common-util/Contracts', () => ({
getComponentContract: jest.fn(),
}));

// TODO: mock updateComponentHashes instead
jest.mock('libs/util-constants/src', () => ({
TOKENOMICS_UNIT_TYPES: { COMPONENT: '0', AGENT: '1' },
}));

describe('listComponents/utils.jsx', () => {
it('getComponentDetails: Promise resolved', async () => {
getComponentContract.mockImplementation(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ jest.mock('common-util/Details/utils', () => ({
checkIfServiceRequiresWhitelisting: jest.fn(),
}));

jest.mock('common-util/Details/DetailsSubInfo/hooks', () => ({
useTokenomicsUnitType: jest.fn(() => 1),
}));


jest.mock('common-util/hooks/useSvmConnectivity', () => ({
useSvmConnectivity: jest.fn(),
}));
Expand Down
4 changes: 3 additions & 1 deletion libs/common-contract-functions/src/lib/useRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Address, formatEther } from 'viem';
import { mainnet } from 'viem/chains';
import { useReadContract } from 'wagmi';

import { TokenomicsUniTypes } from 'libs/util-constants/src';

const rewardsFormatter = (value: bigint, dp: number = 4) =>
parseFloat(formatEther(value)).toLocaleString('en', {
maximumFractionDigits: dp,
Expand All @@ -15,7 +17,7 @@ export const useClaimableIncentives = (
contractAbi: readonly unknown[],
ownerAddress: Address,
id: string,
tokenomicsUnitType?: 0 | 1,
tokenomicsUnitType?: TokenomicsUniTypes,
) => {
const { isFetching, data, refetch } = useReadContract({
address: contractAddress,
Expand Down
1 change: 1 addition & 0 deletions libs/util-constants/src/lib/units.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const TOKENOMICS_UNIT_TYPES = { COMPONENT: '0', AGENT: '1' } as const;
export type TokenomicsUniTypes = (typeof TOKENOMICS_UNIT_TYPES)[keyof typeof TOKENOMICS_UNIT_TYPES];

0 comments on commit bba4959

Please sign in to comment.