Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
einaralex committed Aug 24, 2024
1 parent 4fd0f89 commit b06f43f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
45 changes: 43 additions & 2 deletions packages/sdk-react-provider/src/lib/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { act, renderHook, waitFor } from '@testing-library/react';
import { LinkAddress, NewOrder } from '@monerium/sdk';

import {
useAddress,
useAddresses,
useAuth,
useBalances,
useLinkAddress,
Expand Down Expand Up @@ -42,8 +44,10 @@ jest.mock('@monerium/sdk', () => {
getOrders: mockHook('mockedOrders'),
getOrder: mockHook('mockedOrder'),
getProfile: mockHook('mockedProfile'),
getProfiles: mockHook('mockedProfiles'),
getProfiles: mockHook({ profiles: ['mockedProfiles'] }),
getTokens: mockHook('mockedTokens'),
getAddress: mockHook('mockedAddress'),
getAddresses: mockHook({ addresses: ['mockedAddresses'] }),
getBalances: mockHook('mockedBalances'),
placeOrder: mockHook('mockedPlacedOrder'),
linkAddress: mockHook('mockedLinkedAddress'),
Expand Down Expand Up @@ -188,7 +192,7 @@ describe('useProfiles', () => {
});

await waitFor(() => {
expect(result.current.profiles).toBe('mockedProfiles');
expect(result.current.profiles?.[0]).toBe('mockedProfiles');
expect(result.current.isSuccess).toBe(true);
expect(result.current.isLoading).toBe(false);
});
Expand All @@ -211,6 +215,43 @@ describe('useTokens', () => {
});
});
});
describe('useAddress', () => {
test('returns the address info', async () => {
const { result } = renderHook(
() => useAddress({ address: 'mockedAddress' }),
{
wrapper,
}
);

await waitFor(() => {
expect(result.current.isLoading).toBe(true);
});

await waitFor(() => {
expect(result.current.address).toBe('mockedAddress');
expect(result.current.isSuccess).toBe(true);
expect(result.current.isLoading).toBe(false);
});
});
});
describe('useAddresses', () => {
test('returns the addresses info', async () => {
const { result } = renderHook(() => useAddresses(), {
wrapper,
});

await waitFor(() => {
expect(result.current.isLoading).toBe(true);
});

await waitFor(() => {
expect(result.current.addresses?.[0]).toBe('mockedAddresses');
expect(result.current.isSuccess).toBe(true);
expect(result.current.isLoading).toBe(false);
});
});
});
describe('useBalances', () => {
test('returns the profile', async () => {
const { result } = renderHook(
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react-provider/src/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export function useProfile({
* # Get profiles
* @group Hooks
* @category Profiles
*
* @param {Object} [params] No required parameters.
* @param {QueryOptions<ProfilesResponse>} [params.query] {@inheritDoc QueryOptions}
*
Expand All @@ -202,7 +203,6 @@ export function useProfile({
* ...moreUseQueryResults
* } = useProfiles();
* ```
* @see
* [API Documentation](https://monerium.dev/api-docs#operation/profiles)
*
Expand Down

0 comments on commit b06f43f

Please sign in to comment.