@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
48 lines • 2.23 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const platformAdapter_1 = __importDefault(require("./platformAdapter"));
const live_app_sdk_1 = require("@ledgerhq/live-app-sdk");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
describe("getPlatformTransactionSignFlowInfos", () => {
describe("should properly get infos for BTC platform tx", () => {
test("without fees provided", () => {
const btcPlatformTx = {
family: live_app_sdk_1.FAMILIES.BITCOIN,
amount: new bignumber_js_1.default(100000),
recipient: "0xABCDEF",
};
const expectedLiveTx = {
family: btcPlatformTx.family,
amount: btcPlatformTx.amount,
recipient: btcPlatformTx.recipient,
};
const { canEditFees, hasFeesProvided, liveTx } = platformAdapter_1.default.getPlatformTransactionSignFlowInfos(btcPlatformTx);
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(false);
expect(liveTx).toEqual(expectedLiveTx);
});
test("with fees provided", () => {
const btcPlatformTx = {
family: live_app_sdk_1.FAMILIES.BITCOIN,
amount: new bignumber_js_1.default(100000),
recipient: "0xABCDEF",
feePerByte: new bignumber_js_1.default(300),
};
const expectedLiveTx = {
family: btcPlatformTx.family,
amount: btcPlatformTx.amount,
recipient: btcPlatformTx.recipient,
feePerByte: btcPlatformTx.feePerByte,
feesStrategy: null,
};
const { canEditFees, hasFeesProvided, liveTx } = platformAdapter_1.default.getPlatformTransactionSignFlowInfos(btcPlatformTx);
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(true);
expect(liveTx).toEqual(expectedLiveTx);
});
});
});
//# sourceMappingURL=platformAdapter.test.js.map