UNPKG

@ledgerhq/coin-hedera

Version:
86 lines 2.61 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const bignumber_js_1 = __importDefault(require("bignumber.js")); const utils_1 = require("./utils"); // Balance is 1 Hbar const account = { type: "Account", id: "", seedIdentifier: "", derivationMode: "", index: 0, freshAddress: "", freshAddressPath: "", used: false, balance: new bignumber_js_1.default(100000000), spendableBalance: new bignumber_js_1.default(0), creationDate: new Date(), blockHeight: 0, currency: { type: "CryptoCurrency", id: "hedera", managerAppName: "", coinType: 0, scheme: "", color: "", family: "", explorerViews: [], name: "", ticker: "", units: [], }, operationsCount: 0, operations: [], pendingOperations: [], lastSyncDate: new Date(), balanceHistoryCache: { HOUR: { latestDate: null, balances: [] }, DAY: { latestDate: null, balances: [] }, WEEK: { latestDate: null, balances: [] }, }, swapHistory: [], }; const transaction = { family: "hedera", amount: new bignumber_js_1.default(1), recipient: "", useAllAmount: false, }; describe("utils", () => { let estimatedFees = new bignumber_js_1.default("150200").multipliedBy(2); // 0.001502 ℏ (as of 2023-03-14) beforeAll(async () => { estimatedFees = await (0, utils_1.getEstimatedFees)(account); }); test("calculateAmount transaction.useAllAmount = true", async () => { transaction.useAllAmount = true; const amount = account.balance.minus(estimatedFees); const totalSpent = amount.plus(estimatedFees); const data = { amount, totalSpent, }; const result = await (0, utils_1.calculateAmount)({ account, transaction, }); expect(result).toEqual(data); }); test("calculateAmount transaction.useAllAmount = false", async () => { transaction.useAllAmount = false; const amount = transaction.amount; const totalSpent = amount.plus(estimatedFees); const data = { amount, totalSpent, }; const result = await (0, utils_1.calculateAmount)({ account, transaction, }); expect(result).toEqual(data); }); }); //# sourceMappingURL=utils.integration.test.js.map