aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/0x.js_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-12-22 01:22:28 +0800
committerGitHub <noreply@github.com>2017-12-22 01:22:28 +0800
commit734d220d6050ad7b9fa66e5e0695b848501eeff6 (patch)
treea66808f2d37e852894be4160098566552d3d4f3d /packages/0x.js/test/0x.js_test.ts
parentdc1d2a33a5e9396a57777c992f6c7b49e75480a0 (diff)
parentfffe8c355e9c8d9e9ad4e0d7cdf9822f4df5f399 (diff)
downloaddexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar.gz
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar.bz2
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar.lz
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar.xz
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.tar.zst
dexon-sol-tools-734d220d6050ad7b9fa66e5e0695b848501eeff6.zip
Merge pull request #287 from 0xProject/fix/toBaseUnitAmount
Fix toBaseUnitAmount Issue
Diffstat (limited to 'packages/0x.js/test/0x.js_test.ts')
-rw-r--r--packages/0x.js/test/0x.js_test.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 8d62b3518..245946a89 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -114,6 +114,12 @@ describe('ZeroEx library', () => {
});
});
describe('#toUnitAmount', () => {
+ it('should throw if invalid baseUnit amount supplied as argument', () => {
+ const invalidBaseUnitAmount = new BigNumber(1000000000.4);
+ const decimals = 6;
+ expect(() => ZeroEx.toUnitAmount(invalidBaseUnitAmount, decimals))
+ .to.throw('amount should be in baseUnits (no decimals), found value: 1000000000.4');
+ });
it('Should return the expected unit amount for the decimals passed in', () => {
const baseUnitAmount = new BigNumber(1000000000);
const decimals = 6;
@@ -130,6 +136,12 @@ describe('ZeroEx library', () => {
const expectedUnitAmount = new BigNumber(1000000000);
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
});
+ it('should throw if unitAmount has more decimals then specified as the max decimal precision', () => {
+ const unitAmount = new BigNumber(0.823091);
+ const decimals = 5;
+ expect(() => ZeroEx.toBaseUnitAmount(unitAmount, decimals))
+ .to.throw('Invalid unit amount: 0.823091 - Too many decimal places');
+ });
});
describe('#getOrderHashHex', () => {
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';