Added more tests - format utils

pull/26/head
Vladimir Volek 6 years ago
parent 7b22a965b6
commit 466a0da095

@ -8,7 +8,7 @@
.*/node_modules/react-router/.*
.*/node_modules/react-router-redux/.*
.*/_old/.*
.*/src/solidity/.*
.*/public/.*
[libs]
./src/flowtype/npm/redux_v3.x.x.js

@ -12,11 +12,13 @@ exports[`format utils btckb2satoshib 5`] = `99900000`;
exports[`format utils formatAmount 1`] = `"0 btc"`;
exports[`format utils formatAmount 2`] = `"5e-9 btc"`;
exports[`format utils formatAmount 2`] = `"10 mBTC"`;
exports[`format utils formatAmount 3`] = `"1e-8 eth"`;
exports[`format utils formatAmount 3`] = `"0.000005 mBTC"`;
exports[`format utils formatAmount 4`] = `"0.00099999 undefined"`;
exports[`format utils formatAmount 4`] = `"1e-8 eth"`;
exports[`format utils formatAmount 5`] = `"0.00099999 undefined"`;
exports[`format utils formatTime 1`] = `"No time estimate"`;
@ -28,15 +30,13 @@ exports[`format utils formatTime 4`] = `"1 hour 40 minutes"`;
exports[`format utils formatTime 5`] = `"16 hours 39 minutes"`;
exports[`format utils hexToString 1`] = `""`;
exports[`format utils hexToString 2`] = `"ªªª"`;
exports[`format utils formatTime 6`] = `"45 minutes"`;
exports[`format utils hexToString 3`] = `""`;
exports[`format utils hexToString 1`] = `"test"`;
exports[`format utils hexToString 4`] = `""`;
exports[`format utils hexToString 2`] = `"0001"`;
exports[`format utils hexToString 5`] = `""`;
exports[`format utils hexToString 3`] = `"test99999"`;
exports[`format utils stringToHex 1`] = `"0074006500730074"`;

@ -4,18 +4,19 @@ describe('format utils', () => {
it('formatAmount', () => {
const input = [
{ amount: 0, coinInfo: { isBitcoin: true, currencyUnits: 'mbtc', shortcut: 'btc' } },
{ amount: 1000000, coinInfo: { isBitcoin: true, currencyUnits: 'mbtc', shortcut: 'btc' } },
{ amount: 0.5, coinInfo: { isBitcoin: true, currencyUnits: 'mbtc', shortcut: 'btc' } },
{ amount: 1, coinInfo: { isBitcoin: false, shortcut: 'eth' } },
{ amount: 99999, coinInfo: { isBitcoin: false, currencyUnits: 'tau' } },
];
input.forEach((entry) => {
expect(formatUtils.formatAmount(entry.amount, entry.coinInfo)).toMatchSnapshot();
expect(formatUtils.formatAmount(entry.amount, entry.coinInfo, entry.coinInfo.currencyUnits)).toMatchSnapshot();
});
});
it('formatTime', () => {
const input = [0, 1, 2, 100, 999];
const input = [0, 1, 2, 100, 999, 45];
input.forEach((entry) => {
expect(formatUtils.formatTime(entry)).toMatchSnapshot();
@ -39,7 +40,7 @@ describe('format utils', () => {
});
it('hexToString', () => {
const input = [0, 'xxxtestSringtestStringaaaaaa', 30303031, 2746573743939393939, -9];
const input = ['0074006500730074', '0030003000300031', '007400650073007400390039003900390039'];
input.forEach((entry) => {
expect(formatUtils.hexToString(entry)).toMatchSnapshot();

Loading…
Cancel
Save