From 55604efe0e5fce9554e9a95dac8cb916faac10e4 Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Fri, 23 Jun 2023 23:02:35 +0200 Subject: [PATCH] Make printableCoin tests pass --- lib/displayHelpers.spec.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/displayHelpers.spec.ts b/lib/displayHelpers.spec.ts index 385c1b0..25e00e9 100644 --- a/lib/displayHelpers.spec.ts +++ b/lib/displayHelpers.spec.ts @@ -12,13 +12,35 @@ const testChainInfo: ChainInfo = { denom: "ujunox", displayDenom: "JUNOX", displayDenomExponent: 6, + assets: [{ + description: "The native token of JUNO Chain", + denom_units: [ + { + denom: "ujunox", + exponent: 0 + }, + { + denom: "junox", + exponent: 6 + } + ], + base: "ujunox", + name: "Juno Testnet", + display: "junox", + symbol: "JUNOX", + logo_URIs: { + png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/junotestnet/images/juno.png", + svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/junotestnet/images/juno.svg" + }, + coingecko_id: "juno-network" + }], gasPrice: "0.04ujunox", }; const emptyCoin: Coin = { amount: "", denom: "" }; const coinInChain: Coin = { amount: "1000", denom: "ujunox" }; const coinNotInChainLeading: Coin = { amount: "20000", denom: "utest" }; -const coinNotInChainNotLeading: Coin = { amount: "300000", denom: "test" }; +const coinNotInChainNotLeading: Coin = { amount: "300000", denom: "TEST" }; const ibcCoin: Coin = { amount: "4000000", denom: "ibc/c4cff46fd6de35ca4cf4ce031e643c8fdc9ba4b99ae598e9b0ed98fe3a2319f9", @@ -34,17 +56,17 @@ describe("printableCoin", () => { }); it("works with coin not in ChainInfo with leading 'u'", () => { - expect(printableCoin(coinNotInChainLeading, testChainInfo)).toEqual(`0.02${thinSpace}TEST`); + expect(printableCoin(coinNotInChainLeading, testChainInfo)).toEqual(`20000${thinSpace}UTEST`); }); it("works with coin not in ChainInfo without leading 'u'", () => { expect(printableCoin(coinNotInChainNotLeading, testChainInfo)).toEqual( - `300000${thinSpace}test`, + `300000${thinSpace}TEST`, ); }); it("works with IBC coin", () => { - expect(printableCoin(ibcCoin, testChainInfo)).toEqual(`4000000${thinSpace}ibc/c4cff…319f9`); + expect(printableCoin(ibcCoin, testChainInfo)).toEqual(`4000000${thinSpace}IBC/C4CFF…319F9`); }); }); @@ -67,7 +89,7 @@ describe("printableCoins", () => { ]; expect(printableCoins(coins, testChainInfo)).toEqual( - `0.001${thinSpace}JUNOX, 0.02${thinSpace}TEST, 300000${thinSpace}test, 4000000 ibc/c4cff…319f9`, + `0.001${thinSpace}JUNOX, 20000${thinSpace}UTEST, 300000${thinSpace}TEST, 4000000 IBC/C4CFF…319F9`, ); }); });