From 1ae88eed7a20e68c98e7b05c0cfcf2451468aac7 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 1 Dec 2014 16:02:53 -0300 Subject: [PATCH] Add new test for string values --- test/unit.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/test/unit.js b/test/unit.js index d6f3092..c91aeae 100644 --- a/test/unit.js +++ b/test/unit.js @@ -7,18 +7,39 @@ var Unit = bitcore.Unit; describe('Unit', function() { it('should create an instance', function() { - var unit = new Unit(1.2, "BTC"); + var unit; + + unit = new Unit(1.2, 'BTC'); + should.exist(unit); + + unit = Unit(1.2, 'BTC'); should.exist(unit); }); it('should have property accesors', function() { - var unit = new Unit(1.2, "BTC"); + var unit = new Unit(1.2, 'BTC'); should.exist(unit.BTC); should.exist(unit.mBTC); should.exist(unit.bits); should.exist(unit.satoshis); }); + it('should allow amount as string', function() { + var unit; + + unit = Unit.fromBTC('1.00001'); + unit.BTC.should.equal(1.00001); + + unit = Unit.fromMilis('1.00001'); + unit.mBTC.should.equal(1.00001); + + unit = Unit.fromBits('100'); + unit.bits.should.equal(100); + + unit = Unit.fromSatoshis('8999'); + unit.satoshis.should.equal(8999); + }); + it('should have constructor helpers', function() { var unit;