Make printableCoin tests pass

This commit is contained in:
abefernan 2023-06-23 23:02:35 +02:00
parent 312bfb5ba2
commit 55604efe0e

View File

@ -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, 4000000ibc/c4cff…319f9`,
`0.001${thinSpace}JUNOX, 20000${thinSpace}UTEST, 300000${thinSpace}TEST, 4000000IBC/C4CFF…319F9`,
);
});
});