aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/test
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-14 09:31:54 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-14 09:31:54 +0800
commit84215f75e046597eb34f9d5409bd45410a0819e6 (patch)
treee6c57cdd7bc5064bdd6752d99c35779f3c1200c7 /packages/instant/test
parent35bfd493e87b5d6c76f5bb2176b0992891a4a555 (diff)
parent4fc457b78b30e761164eac26fe5f1ebcddd11f7d (diff)
downloaddexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar.gz
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar.bz2
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar.lz
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar.xz
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.tar.zst
dexon-sol-tools-84215f75e046597eb34f9d5409bd45410a0819e6.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/different-install-wallet-copy-for-mobile
Diffstat (limited to 'packages/instant/test')
-rw-r--r--packages/instant/test/util/format.test.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/packages/instant/test/util/format.test.ts b/packages/instant/test/util/format.test.ts
index c346b7604..fe0a63e6e 100644
--- a/packages/instant/test/util/format.test.ts
+++ b/packages/instant/test/util/format.test.ts
@@ -15,20 +15,20 @@ const BIG_NUMBER_FAKE_ETH_USD_PRICE = new BigNumber(2.534);
describe('format', () => {
describe('ethBaseAmount', () => {
it('converts 1 ETH in base units to the string `1 ETH`', () => {
- expect(format.ethBaseAmount(ONE_ETH_IN_BASE_UNITS)).toBe('1 ETH');
+ expect(format.ethBaseUnitAmount(ONE_ETH_IN_BASE_UNITS)).toBe('1 ETH');
});
it('converts .432414 ETH in base units to the string `.4324 ETH`', () => {
- expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS)).toBe('0.4324 ETH');
+ expect(format.ethBaseUnitAmount(DECIMAL_ETH_IN_BASE_UNITS)).toBe('0.4324 ETH');
});
it('converts 5.3014059295032 ETH in base units to the string `5.301 ETH`', () => {
- expect(format.ethBaseAmount(IRRATIONAL_ETH_IN_BASE_UNITS)).toBe('5.301 ETH');
+ expect(format.ethBaseUnitAmount(IRRATIONAL_ETH_IN_BASE_UNITS)).toBe('5.301 ETH');
});
it('returns defaultText param when ethBaseAmount is not defined', () => {
const defaultText = 'defaultText';
- expect(format.ethBaseAmount(undefined, 4, defaultText)).toBe(defaultText);
+ expect(format.ethBaseUnitAmount(undefined, 4, defaultText)).toBe(defaultText);
});
it('it allows for configurable decimal places', () => {
- expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS, 2)).toBe('0.43 ETH');
+ expect(format.ethBaseUnitAmount(DECIMAL_ETH_IN_BASE_UNITS, 2)).toBe('0.43 ETH');
});
});
describe('ethUnitAmount', () => {
@@ -52,24 +52,26 @@ describe('format', () => {
});
describe('ethBaseAmountInUsd', () => {
it('correctly formats 1 ETH to usd according to some price', () => {
- expect(format.ethBaseAmountInUsd(ONE_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53');
+ expect(format.ethBaseUnitAmountInUsd(ONE_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53');
});
it('correctly formats .432414 ETH to usd according to some price', () => {
- expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$1.10');
+ expect(format.ethBaseUnitAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe(
+ '$1.10',
+ );
});
it('correctly formats 5.3014059295032 ETH to usd according to some price', () => {
- expect(format.ethBaseAmountInUsd(IRRATIONAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe(
+ expect(format.ethBaseUnitAmountInUsd(IRRATIONAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe(
'$13.43',
);
});
it('returns defaultText param when ethBaseAmountInUsd or ethUsdPrice is not defined', () => {
const defaultText = 'defaultText';
- expect(format.ethBaseAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText);
- expect(format.ethBaseAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText);
- expect(format.ethBaseAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText);
+ expect(format.ethBaseUnitAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethBaseUnitAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethBaseUnitAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText);
});
it('it allows for configurable decimal places', () => {
- expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe(
+ expect(format.ethBaseUnitAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe(
'$1.0957',
);
});