@ledgerhq/coin-aptos
Version:
Ledger Aptos Coin integration
45 lines • 2.46 kB
JavaScript
"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 calculateAmount_1 = require("../../logic/calculateAmount");
describe("calculateAmount", () => {
it("should calculate the correct amount when the address is the sender", () => {
const address = "0x11";
const sender = "0x11";
const amount_in = new bignumber_js_1.default(50);
const amount_out = new bignumber_js_1.default(100);
const result = (0, calculateAmount_1.calculateAmount)(sender, address, amount_in, amount_out);
// LL negates the amount for SEND transactions during output
expect(result).toEqual(new bignumber_js_1.default(50)); // -(50 - 100 - 10)
});
it("should calculate the correct amount when the address is not the sender", () => {
const address = "0x11";
const sender = "0x12";
const amount_in = new bignumber_js_1.default(100);
const amount_out = new bignumber_js_1.default(50);
const result = (0, calculateAmount_1.calculateAmount)(sender, address, amount_in, amount_out);
expect(result).toEqual(new bignumber_js_1.default(50)); // 100 - 50
});
it("should handle transactions with zero amounts", () => {
const address = "0x11";
const sender = "0x11";
const amount_in = new bignumber_js_1.default(0);
const amount_out = new bignumber_js_1.default(0);
const result = (0, calculateAmount_1.calculateAmount)(sender, address, amount_in, amount_out);
// LL negates the amount for SEND transactions during output
expect(result).toEqual(new bignumber_js_1.default(0)); // -(0 - 0 - 10)
});
it("should get negative numbers (for send tx with deposit to account)", () => {
const address = "0x11";
const sender = "0x11";
const amount_in = new bignumber_js_1.default(100);
const amount_out = new bignumber_js_1.default(0);
const result = (0, calculateAmount_1.calculateAmount)(sender, address, amount_in, amount_out);
// LL negates the amount for SEND transactions during output
expect(result).toEqual(new bignumber_js_1.default(100).negated()); // 100 - 10
});
});
//# sourceMappingURL=calculateAmount.unit.test.js.map