@ledgerhq/live-common 34.53.0-nightly.20251118023800 → 34.53.0-nightly.20251119023741
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +0 -4
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +12 -10
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/deposit/type.d.ts +0 -17
- package/lib/deposit/type.d.ts.map +1 -1
- package/lib/deposit/type.js.map +1 -1
- package/lib/deviceSDK/tasks/core.d.ts +1 -1
- package/lib/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/core.js +1 -1
- package/lib/deviceSDK/tasks/core.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +0 -1
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +0 -1
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +0 -1
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +1 -5
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts +6 -0
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts.map +1 -0
- package/lib/e2e/enum/ReceiveFundsOptions.js +8 -0
- package/lib/e2e/enum/ReceiveFundsOptions.js.map +1 -0
- package/lib/exchange/providers/swap.d.ts +1 -0
- package/lib/exchange/providers/swap.d.ts.map +1 -1
- package/lib/exchange/providers/swap.js +5 -1
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js +2 -3
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js +15 -10
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib/market/hooks/useMarketDataProvider.js +1 -0
- package/lib/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib/market/utils/types.d.ts +1 -0
- package/lib/market/utils/types.d.ts.map +1 -1
- package/lib/market/utils/types.js.map +1 -1
- package/lib/modularDrawer/utils/{groupCurrenciesByProvider.d.ts → groupCurrenciesByAsset.d.ts} +2 -2
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +1 -0
- package/lib/modularDrawer/utils/{groupCurrenciesByProvider.js → groupCurrenciesByAsset.js} +7 -7
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.js.map +1 -0
- package/lib/modularDrawer/utils/index.d.ts +1 -1
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +3 -3
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/wallet-api/types.d.ts +3 -0
- package/lib/wallet-api/types.d.ts.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts +6 -0
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js +13 -3
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +0 -4
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +13 -11
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/deposit/type.d.ts +0 -17
- package/lib-es/deposit/type.d.ts.map +1 -1
- package/lib-es/deposit/type.js.map +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/core.js +1 -1
- package/lib-es/deviceSDK/tasks/core.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +0 -1
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +0 -1
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +0 -1
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +1 -5
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts +6 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts.map +1 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.js +5 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.js.map +1 -0
- package/lib-es/exchange/providers/swap.d.ts +1 -0
- package/lib-es/exchange/providers/swap.d.ts.map +1 -1
- package/lib-es/exchange/providers/swap.js +3 -0
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js +2 -3
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js +17 -12
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib-es/market/hooks/useMarketDataProvider.js +1 -0
- package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib-es/market/utils/types.d.ts +1 -0
- package/lib-es/market/utils/types.d.ts.map +1 -1
- package/lib-es/market/utils/types.js.map +1 -1
- package/lib-es/modularDrawer/utils/{groupCurrenciesByProvider.d.ts → groupCurrenciesByAsset.d.ts} +2 -2
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/{groupCurrenciesByProvider.js → groupCurrenciesByAsset.js} +5 -5
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.js.map +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts +1 -1
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +1 -1
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/wallet-api/types.d.ts +3 -0
- package/lib-es/wallet-api/types.d.ts.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts +6 -0
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js +11 -2
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/package.json +54 -54
- package/src/__tests__/test-helpers/bridge.ts +0 -2
- package/src/bridge/generic-alpaca/getAccountShape.ts +15 -12
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +142 -101
- package/src/deposit/type.ts +0 -21
- package/src/deviceSDK/tasks/core.test.ts +20 -0
- package/src/deviceSDK/tasks/core.ts +2 -1
- package/src/e2e/enum/Account.ts +0 -6
- package/src/e2e/enum/Currency.ts +1 -5
- package/src/e2e/enum/ReceiveFundsOptions.ts +7 -0
- package/src/exchange/providers/swap.ts +4 -0
- package/src/exchange/swap/hooks/v5/useFetchCurrencyAll.ts +2 -3
- package/src/exchange/swap/hooks/v5/useFilteredProviders.ts +37 -12
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +84 -12
- package/src/market/hooks/useMarketDataProvider.ts +1 -0
- package/src/market/utils/types.ts +1 -0
- package/src/modularDrawer/modules/__test__/createAssetConfiguration.test.tsx +2 -2
- package/src/modularDrawer/utils/__tests__/{groupCurrenciesByProvider.test.ts → groupCurrenciesByAsset.test.ts} +6 -6
- package/src/modularDrawer/utils/{groupCurrenciesByProvider.ts → groupCurrenciesByAsset.ts} +4 -4
- package/src/modularDrawer/utils/index.ts +1 -1
- package/src/wallet-api/types.ts +5 -0
- package/src/wallet-api/utils/deriveAccountIdForManifest.ts +14 -2
- package/lib/deposit/helper.d.ts +0 -8
- package/lib/deposit/helper.d.ts.map +0 -1
- package/lib/deposit/helper.js +0 -125
- package/lib/deposit/helper.js.map +0 -1
- package/lib/deposit/index.d.ts +0 -3
- package/lib/deposit/index.d.ts.map +0 -1
- package/lib/deposit/index.js +0 -6
- package/lib/deposit/index.js.map +0 -1
- package/lib/deposit/mock.d.ts +0 -75
- package/lib/deposit/mock.d.ts.map +0 -1
- package/lib/deposit/mock.js +0 -15111
- package/lib/deposit/mock.js.map +0 -1
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts +0 -3
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +0 -1
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js +0 -40
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js.map +0 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +0 -22
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +0 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +0 -41
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +0 -1
- package/lib/modularDrawer/utils/currencyUtils.d.ts +0 -10
- package/lib/modularDrawer/utils/currencyUtils.d.ts.map +0 -1
- package/lib/modularDrawer/utils/currencyUtils.js +0 -74
- package/lib/modularDrawer/utils/currencyUtils.js.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.js.map +0 -1
- package/lib-es/deposit/helper.d.ts +0 -8
- package/lib-es/deposit/helper.d.ts.map +0 -1
- package/lib-es/deposit/helper.js +0 -117
- package/lib-es/deposit/helper.js.map +0 -1
- package/lib-es/deposit/index.d.ts +0 -3
- package/lib-es/deposit/index.d.ts.map +0 -1
- package/lib-es/deposit/index.js +0 -3
- package/lib-es/deposit/index.js.map +0 -1
- package/lib-es/deposit/mock.d.ts +0 -75
- package/lib-es/deposit/mock.d.ts.map +0 -1
- package/lib-es/deposit/mock.js +0 -15108
- package/lib-es/deposit/mock.js.map +0 -1
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts +0 -3
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +0 -1
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js +0 -36
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js.map +0 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +0 -22
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +0 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +0 -38
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +0 -1
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts +0 -10
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/currencyUtils.js +0 -65
- package/lib-es/modularDrawer/utils/currencyUtils.js.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.js.map +0 -1
- package/src/deposit/deposit.integration.test.ts +0 -88
- package/src/deposit/deposit.test.ts +0 -684
- package/src/deposit/helper.ts +0 -143
- package/src/deposit/index.ts +0 -3
- package/src/deposit/mock.ts +0 -15112
- package/src/deposit/useGroupedCurrenciesByProvider.hook.ts +0 -46
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +0 -49
- package/src/modularDrawer/modules/__test__/createNetworkConfiguration.test.ts +0 -342
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +0 -126
- package/src/modularDrawer/utils/currencyUtils.ts +0 -95
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { getTokenOrCryptoCurrencyById } from "../../deposit/helper";
|
|
2
|
-
import { isTokenCurrency } from "../../currencies";
|
|
3
|
-
export const safeCurrencyLookup = async (id) => {
|
|
4
|
-
try {
|
|
5
|
-
return await getTokenOrCryptoCurrencyById(id);
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export const isProviderToken = (currency, providerId) => {
|
|
12
|
-
return isTokenCurrency(currency) && currency.id.toLowerCase().includes(providerId.toLowerCase());
|
|
13
|
-
};
|
|
14
|
-
export const getProviderCurrency = async (provider) => {
|
|
15
|
-
const providerToken = provider.currenciesByNetwork.find(currency => {
|
|
16
|
-
return isProviderToken(currency, provider.providerId);
|
|
17
|
-
});
|
|
18
|
-
if (providerToken) {
|
|
19
|
-
return providerToken;
|
|
20
|
-
}
|
|
21
|
-
const lookupResult = await safeCurrencyLookup(provider.providerId);
|
|
22
|
-
return lookupResult ?? provider.currenciesByNetwork[0];
|
|
23
|
-
};
|
|
24
|
-
export const buildProviderCoverageMap = (providers) => {
|
|
25
|
-
const providerIdToCoveringProviders = new Map();
|
|
26
|
-
for (const { providerId, currenciesByNetwork } of providers) {
|
|
27
|
-
for (const { id } of currenciesByNetwork) {
|
|
28
|
-
if (!providerIdToCoveringProviders.has(id)) {
|
|
29
|
-
providerIdToCoveringProviders.set(id, new Set());
|
|
30
|
-
}
|
|
31
|
-
providerIdToCoveringProviders.get(id).add(providerId);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return providerIdToCoveringProviders;
|
|
35
|
-
};
|
|
36
|
-
export const filterProvidersByIds = (providers, currencyIdsSet, providerCoverageMap) => {
|
|
37
|
-
const filtered = [];
|
|
38
|
-
for (const provider of providers) {
|
|
39
|
-
const filteredCurrencies = provider.currenciesByNetwork.filter(currency => currencyIdsSet.has(currency.id));
|
|
40
|
-
if (filteredCurrencies.length === 0)
|
|
41
|
-
continue;
|
|
42
|
-
const providerHasOwnCurrency = provider.currenciesByNetwork.some(currency => currency.id === provider.providerId);
|
|
43
|
-
if (!providerHasOwnCurrency) {
|
|
44
|
-
const coveringProviders = providerCoverageMap.get(provider.providerId);
|
|
45
|
-
const isProviderIdCoveredElsewhere = coveringProviders && coveringProviders.size > 1;
|
|
46
|
-
if (isProviderIdCoveredElsewhere)
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (filteredCurrencies.length === provider.currenciesByNetwork.length) {
|
|
50
|
-
filtered.push(provider);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
filtered.push({
|
|
54
|
-
...provider,
|
|
55
|
-
currenciesByNetwork: filteredCurrencies,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return filtered;
|
|
60
|
-
};
|
|
61
|
-
export const extractProviderCurrencies = async (providers) => {
|
|
62
|
-
const currencies = await Promise.all(providers.map(provider => getProviderCurrency(provider)));
|
|
63
|
-
return currencies.filter((currency) => currency !== null);
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=currencyUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currencyUtils.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/currencyUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EAAU,EAAyC,EAAE;IAC5F,IAAI;QACF,OAAO,MAAM,4BAA4B,CAAC,EAAE,CAAC,CA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,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/F,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAqC,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;AAC/F,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupCurrenciesByProvider.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/groupCurrenciesByProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,eAAO,MAAM,yBAAyB,iBAAkB,SAAS,EAAE;kBAG/C,qBAAqB;gBAAc,qBAAqB,EAAE;EAoB7E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupCurrenciesByProvider.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/groupCurrenciesByProvider.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,YAAyB,EAAE,EAAE;IACrE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAGrB,CAAC;IAEJ,IAAI,YAAY,EAAE;QAChB,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;YAC/B,MAAM,EACJ,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EACzB,QAAQ,GAAG,EAAE,GACd,GAAG,IAAI,CAAC;YACT,IAAI,QAAQ,EAAE,MAAM,GAAG,CAAC,EAAE;gBACxB,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC5E,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE;oBACvB,YAAY;oBACZ,UAAU,EAAE,QAAQ;iBACrB,CAAC,CAAC;aACJ;SACF;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
|
-
import "../__tests__/test-helpers/setup";
|
|
5
|
-
import { renderHook, waitFor } from "@testing-library/react";
|
|
6
|
-
import { useGroupedCurrenciesByProvider } from ".";
|
|
7
|
-
import { GroupedCurrencies, LoadingBasedGroupedCurrencies, MappedAsset } from "./type";
|
|
8
|
-
import * as api from "./api";
|
|
9
|
-
|
|
10
|
-
// Mock dependencies for useAcceptedCurrency
|
|
11
|
-
jest.mock("../featureFlags", () => ({
|
|
12
|
-
useFeature: jest.fn().mockReturnValue({ enabled: true }),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
jest.mock("../hooks/useEnv", () => jest.fn().mockReturnValue(false));
|
|
16
|
-
|
|
17
|
-
// Mock the countervalues API for currenciesByMarketcap
|
|
18
|
-
jest.mock("@ledgerhq/live-countervalues/api/index", () => ({
|
|
19
|
-
__esModule: true,
|
|
20
|
-
default: {
|
|
21
|
-
fetchIdsSortedByMarketcap: jest.fn().mockResolvedValue(["bitcoin", "ethereum"]),
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
// Mock the API module
|
|
26
|
-
jest.mock("./api");
|
|
27
|
-
const mockGetMappedAssets = api.getMappedAssets as jest.MockedFunction<typeof api.getMappedAssets>;
|
|
28
|
-
|
|
29
|
-
// Create mock data for testing
|
|
30
|
-
const mockMappedAssets: MappedAsset[] = [
|
|
31
|
-
{
|
|
32
|
-
$type: "Coin",
|
|
33
|
-
ledgerId: "bitcoin",
|
|
34
|
-
providerId: "coingecko",
|
|
35
|
-
name: "Bitcoin",
|
|
36
|
-
ticker: "BTC",
|
|
37
|
-
status: "active",
|
|
38
|
-
reason: null,
|
|
39
|
-
data: {
|
|
40
|
-
img: "https://crypto-icons.example.com/bitcoin.png",
|
|
41
|
-
marketCapRank: 1,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
$type: "Coin",
|
|
46
|
-
ledgerId: "ethereum",
|
|
47
|
-
providerId: "coingecko",
|
|
48
|
-
name: "Ethereum",
|
|
49
|
-
ticker: "ETH",
|
|
50
|
-
status: "active",
|
|
51
|
-
reason: null,
|
|
52
|
-
data: {
|
|
53
|
-
img: "https://crypto-icons.example.com/ethereum.png",
|
|
54
|
-
marketCapRank: 2,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
describe("useGroupedCurrenciesByProvider", () => {
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
// Mock the API call to return our test data
|
|
62
|
-
mockGetMappedAssets.mockResolvedValue(mockMappedAssets);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
afterEach(() => {
|
|
66
|
-
jest.clearAllMocks();
|
|
67
|
-
});
|
|
68
|
-
it("should list is starting with Bitcoin", async () => {
|
|
69
|
-
const { result } = renderHook(() => useGroupedCurrenciesByProvider(false));
|
|
70
|
-
await waitFor(() =>
|
|
71
|
-
expect(
|
|
72
|
-
(result.current as GroupedCurrencies).sortedCryptoCurrencies.slice(0, 1).map(o => o.id),
|
|
73
|
-
).toMatchObject(["bitcoin"]),
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should list is starting with Bitcoin when withLoading is activated", async () => {
|
|
78
|
-
const { result: hookRef } = renderHook(() => useGroupedCurrenciesByProvider(true));
|
|
79
|
-
|
|
80
|
-
await waitFor(() =>
|
|
81
|
-
expect(
|
|
82
|
-
(hookRef.current as LoadingBasedGroupedCurrencies).result.sortedCryptoCurrencies
|
|
83
|
-
.slice(0, 1)
|
|
84
|
-
.map(o => o.id),
|
|
85
|
-
).toMatchObject(["bitcoin"]),
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
});
|