UNPKG

@xlink-network/xlink-sdk

Version:
46 lines (45 loc) 1.37 kB
import { BigNumber } from "../chunk-KHTJNOQE.mjs"; import "../chunk-PRLWYSC3.mjs"; import "../chunk-ZLTA3V7U.mjs"; // src/utils/BigNumber.spec.ts import { describe, expect, it } from "vitest"; describe("BigNumber", () => { describe("round", () => { describe("roundHalfEven", () => { it("should round to the nearest even number", () => { const t = (expected, value, precision) => { expect( BigNumber.round( { precision, roundingMode: BigNumber.roundHalfEven }, value ), `t("${expected}", "${value}", ${precision})` ).toEqual(BigNumber.from(expected)); }; t("123.4", "123.45", 1); t("123.4", "123.35", 1); t("123.4", "123.41", 1); t("123.4", "123.36", 1); }); }); }); describe("sum", () => { it("should return the sum of an array of BigNumber values", () => { const numbers = [1, BigNumber.from(2), "3"]; expect(BigNumber.sum(numbers)).toEqual(BigNumber.from(6)); }); }); describe("getDecimalPart", () => { it("should return the decimal part of a BigNumber value", () => { expect(BigNumber.getDecimalPart({ precision: 10 }, "123.45")).toEqual( "45" ); }); }); }); //# sourceMappingURL=BigNumber.spec.mjs.map