diff options
author | Fabio Berger <me@fabioberger.com> | 2018-12-19 22:16:35 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-12-19 22:16:35 +0800 |
commit | 293dadc22aedcaf540f2dc17c8c38087e7ace037 (patch) | |
tree | 79f624ab03071a28da83c7bf542acfe0dd7af8cb /packages/instant/test | |
parent | ddf3bb7c0446f2d85b6fa55cbe0b00b227f08af7 (diff) | |
parent | 040b402b6d558d13f2f4e032297b6723cdf2aafe (diff) | |
download | dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar.gz dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar.bz2 dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar.lz dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar.xz dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.tar.zst dexon-sol-tools-293dadc22aedcaf540f2dc17c8c38087e7ace037.zip |
Merge branch 'development' into website/addPySRA
* development: (141 commits)
Add missing CHANGELOG entry for OrderWatcher WS interface
Bump up stale to close to 30 days
Move onMessageAsync outside of tests and add comments
Fix WS tests to remove race-condition and be more specific about the message expected
Add temporary console.log to test failing on CI
Make @0x/contracts-test-utils a dependency instead of a devDependency
Fix test-publish failure in contracts packages
Fixed solhint errors
Added documentation to `LibAddressArray.append` and switched `if` to `require` smt
Updated changelogs for new contracts
Added `gas` field so tests pass on Geth;
Added Changelog for new Extensions
Updated comment `Execute fillOrder` -> `Execute exchange function`
Explicit returns
Prettier / Linter on contracts + TS
Refactoring balance threshold filter
Moved exchange calldata functions to separate mixin
Less Assembly. More Solidity. Less Efficiency. More Readability.
Run all tests for extensions
Cleaned up tests for balance threshold filter
...
Diffstat (limited to 'packages/instant/test')
-rw-r--r-- | packages/instant/test/util/format.test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/instant/test/util/format.test.ts b/packages/instant/test/util/format.test.ts index fe0a63e6e..38bf356ec 100644 --- a/packages/instant/test/util/format.test.ts +++ b/packages/instant/test/util/format.test.ts @@ -41,6 +41,18 @@ describe('format', () => { it('converts BigNumber(5.3014059295032) to the string `5.301 ETH`', () => { expect(format.ethUnitAmount(BIG_NUMBER_IRRATIONAL)).toBe('5.301 ETH'); }); + it('shows 1 significant digit when rounded amount would be 0', () => { + expect(format.ethUnitAmount(new BigNumber(0.00003))).toBe('0.00003 ETH'); + expect(format.ethUnitAmount(new BigNumber(0.000034))).toBe('0.00003 ETH'); + expect(format.ethUnitAmount(new BigNumber(0.000035))).toBe('0.00004 ETH'); + }); + it('shows < 0.00001 when hits threshold', () => { + expect(format.ethUnitAmount(new BigNumber(0.000011))).toBe('0.00001 ETH'); + expect(format.ethUnitAmount(new BigNumber(0.00001))).toBe('0.00001 ETH'); + expect(format.ethUnitAmount(new BigNumber(0.000009))).toBe('< 0.00001 ETH'); + expect(format.ethUnitAmount(new BigNumber(0.0000000009))).toBe('< 0.00001 ETH'); + expect(format.ethUnitAmount(new BigNumber(0))).toBe('0 ETH'); + }); it('returns defaultText param when ethUnitAmount is not defined', () => { const defaultText = 'defaultText'; expect(format.ethUnitAmount(undefined, 4, defaultText)).toBe(defaultText); @@ -86,6 +98,12 @@ describe('format', () => { it('correctly formats 5.3014059295032 ETH to usd according to some price', () => { expect(format.ethUnitAmountInUsd(BIG_NUMBER_IRRATIONAL, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$13.43'); }); + it('correctly formats amount that is less than 1 cent', () => { + expect(format.ethUnitAmountInUsd(new BigNumber(0.000001), BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('<$0.01'); + }); + it('correctly formats exactly 1 cent', () => { + expect(format.ethUnitAmountInUsd(new BigNumber(0.0039), BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$0.01'); + }); it('returns defaultText param when ethUnitAmountInUsd or ethUsdPrice is not defined', () => { const defaultText = 'defaultText'; expect(format.ethUnitAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText); |