UNPKG

@ledgerhq/coin-ton

Version:
30 lines 1.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("../../bridge/bridgeHelpers/api"); const estimateMaxSpendable_1 = __importDefault(require("../../estimateMaxSpendable")); const common_fixtures_1 = require("../fixtures/common.fixtures"); jest.mock("../../bridge/bridgeHelpers/api"); describe("estimateMaxSpendable", () => { beforeAll(() => { const fetchAccountInfoMock = jest.mocked(api_1.fetchAccountInfo); fetchAccountInfoMock.mockReturnValue(Promise.resolve(common_fixtures_1.accountInfo)); const fetchEstimateFeeMock = jest.mocked(api_1.estimateFee); fetchEstimateFeeMock.mockReturnValue(Promise.resolve(common_fixtures_1.fees)); }); it("should return the max spendable for a TON transaction", async () => { const res = await (0, estimateMaxSpendable_1.default)({ account: common_fixtures_1.account, transaction: common_fixtures_1.transaction }); expect(res).toEqual(common_fixtures_1.account.balance.minus(common_fixtures_1.totalFees)); }); it("should return the max spendable for a jetton transfer", async () => { const res = await (0, estimateMaxSpendable_1.default)({ account: common_fixtures_1.tokenAccount, parentAccount: common_fixtures_1.account, transaction: common_fixtures_1.jettonTransaction, }); expect(res).toEqual(common_fixtures_1.tokenAccount.spendableBalance); }); }); //# sourceMappingURL=estimateMaxSpendable.unit.test.js.map