UNPKG

@ledgerhq/coin-hedera

Version:
58 lines 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const bignumber_js_1 = require("bignumber.js"); const cryptoassets_1 = require("@ledgerhq/cryptoassets"); const logic_1 = require("./logic"); describe("getTransactionExplorer", () => { test("Tx explorer URL is converted from hash to consensus timestamp", async () => { const explorerView = (0, cryptoassets_1.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_js_1.BigNumber(0), fee: new bignumber_js_1.BigNumber(0), senders: [], recipients: [], blockHeight: undefined, blockHash: undefined, accountId: "", date: new Date(), }; const newUrl = (0, logic_1.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 = (0, cryptoassets_1.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_js_1.BigNumber(0), fee: new bignumber_js_1.BigNumber(0), senders: [], recipients: [], blockHeight: undefined, blockHash: undefined, accountId: "", date: new Date(), }; const newUrl = (0, logic_1.getTransactionExplorer)(explorerView, mockOperation); expect(newUrl).toBe("https://hashscan.io/mainnet/transaction/0.0.1234567-123-123"); }); }); //# sourceMappingURL=logic.test.js.map