UNPKG

@ledgerhq/coin-icon

Version:
71 lines 2.61 kB
import { BigNumber } from "bignumber.js"; import { assignFromAccountRaw, assignToAccountRaw, fromIconResourcesRaw, toIconResourcesRaw, } from "../../serialization"; describe("Icon Resources Utilities", () => { describe("toIconResourcesRaw", () => { it("should convert IconResources to IconResourcesRaw", () => { const resources = { nonce: 1, votingPower: new BigNumber(1000), totalDelegated: new BigNumber(2000), }; const expectedRaw = { nonce: 1, votingPower: "1000", totalDelegated: "2000", }; expect(toIconResourcesRaw(resources)).toEqual(expectedRaw); }); }); describe("fromIconResourcesRaw", () => { it("should convert IconResourcesRaw to IconResources", () => { const rawResources = { nonce: 1, votingPower: "1000", totalDelegated: "2000", }; const expectedResources = { nonce: 1, votingPower: new BigNumber(1000), totalDelegated: new BigNumber(2000), }; expect(fromIconResourcesRaw(rawResources)).toEqual(expectedResources); }); }); describe("assignToAccountRaw", () => { it("should assign IconResources to AccountRaw", () => { const account = { iconResources: { nonce: 1, votingPower: new BigNumber(1000), totalDelegated: new BigNumber(2000), }, }; const accountRaw = {}; assignToAccountRaw(account, accountRaw); expect(accountRaw.iconResources).toEqual({ nonce: 1, votingPower: "1000", totalDelegated: "2000", }); }); }); describe("assignFromAccountRaw", () => { it("should assign IconResourcesRaw to Account", () => { const accountRaw = { iconResources: { nonce: 1, votingPower: "1000", totalDelegated: "2000", }, }; const account = {}; assignFromAccountRaw(accountRaw, account); expect(account.iconResources).toEqual({ nonce: 1, votingPower: new BigNumber(1000), totalDelegated: new BigNumber(2000), }); }); }); }); //# sourceMappingURL=serializations.unit.test.js.map