@ledgerhq/coin-hedera
Version:
Ledger Hedera Coin integration
56 lines • 2.09 kB
JavaScript
import { BigNumber } from "bignumber.js";
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
import { getTransactionExplorer } from "./logic";
describe("getTransactionExplorer", () => {
test("Tx explorer URL is converted from hash to consensus timestamp", async () => {
const explorerView = getCryptoCurrencyById("hedera").explorerViews[0];
expect(explorerView).toEqual({
tx: expect.any(String),
address: expect.any(String),
});
const mockOperation = {
extra: {
consensusTimestamp: "1.2.3.4",
},
id: "",
hash: "",
type: "IN",
value: new BigNumber(0),
fee: new BigNumber(0),
senders: [],
recipients: [],
blockHeight: undefined,
blockHash: undefined,
accountId: "",
date: new Date(),
};
const newUrl = getTransactionExplorer(explorerView, mockOperation);
expect(newUrl).toBe("https://hashscan.io/mainnet/transaction/1.2.3.4");
});
test("Tx explorer URL is based on transaction id if consensus timestamp is not available", async () => {
const explorerView = getCryptoCurrencyById("hedera").explorerViews[0];
expect(explorerView).toEqual({
tx: expect.any(String),
address: expect.any(String),
});
const mockOperation = {
extra: {
transactionId: "0.0.1234567-123-123",
},
id: "",
hash: "",
type: "IN",
value: new BigNumber(0),
fee: new BigNumber(0),
senders: [],
recipients: [],
blockHeight: undefined,
blockHash: undefined,
accountId: "",
date: new Date(),
};
const newUrl = getTransactionExplorer(explorerView, mockOperation);
expect(newUrl).toBe("https://hashscan.io/mainnet/transaction/0.0.1234567-123-123");
});
});
//# sourceMappingURL=logic.test.js.map