@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
38 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
const cryptoCurrencies_1 = require("../../mock/fixtures/cryptoCurrencies");
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
describe("isCorrespondingCurrency", () => {
const evmCurrency = (0, cryptoCurrencies_1.createFixtureCryptoCurrency)("evm");
const usdcToken = {
type: "TokenCurrency",
id: "ethereum/erc20/usdc",
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
parentCurrency: evmCurrency,
tokenType: "erc20",
name: "USD Coin",
ticker: "USDC",
units: [{ name: "USD Coin", code: "USDC", magnitude: 6 }],
};
const evmCrypto = evmCurrency;
it("returns true for a token whose parentCurrency.id matches the reference crypto", () => {
expect((0, index_1.isCorrespondingCurrency)(usdcToken, evmCurrency)).toBe(true);
});
it("returns true for a token whose id matches the reference crypto", () => {
expect((0, index_1.isCorrespondingCurrency)(usdcToken, usdcToken)).toBe(true);
});
it("returns true for a crypto whose id matches the reference crypto", () => {
expect((0, index_1.isCorrespondingCurrency)(evmCrypto, evmCurrency)).toBe(true);
});
it("returns false for a token whose parentCurrency is different", () => {
const bitcoinCurrency = cryptoassets_1.cryptocurrenciesById["bitcoin"];
const tokenWithOtherParent = { ...usdcToken, parentCurrency: bitcoinCurrency };
expect((0, index_1.isCorrespondingCurrency)(tokenWithOtherParent, evmCurrency)).toBe(false);
});
it("returns false for a crypto whose id is different", () => {
const bitcoinCurrency = cryptoassets_1.cryptocurrenciesById["bitcoin"];
expect((0, index_1.isCorrespondingCurrency)(bitcoinCurrency, evmCurrency)).toBe(false);
});
});
//# sourceMappingURL=index.test.js.map