web3.js/test/utils.toWei.js

38 lines
2.0 KiB
JavaScript
Raw Normal View History

2015-03-08 09:07:32 +00:00
var chai = require('chai');
2015-03-08 17:18:52 +00:00
var utils = require('../lib/utils/utils');
2015-03-08 09:07:32 +00:00
var assert = chai.assert;
2015-03-25 21:17:35 +00:00
describe('lib/utils/utils', function () {
describe('toWei', function () {
it('should return the correct value', function () {
2015-02-23 09:01:00 +00:00
assert.equal(utils.toWei(1, 'wei'), '1');
assert.equal(utils.toWei(1, 'kwei'), '1000');
assert.equal(utils.toWei(1, 'Kwei'), '1000');
assert.equal(utils.toWei(1, 'babbage'), '1000');
2015-02-23 09:01:00 +00:00
assert.equal(utils.toWei(1, 'mwei'), '1000000');
assert.equal(utils.toWei(1, 'Mwei'), '1000000');
assert.equal(utils.toWei(1, 'lovelace'), '1000000');
2015-02-23 09:01:00 +00:00
assert.equal(utils.toWei(1, 'gwei'), '1000000000');
assert.equal(utils.toWei(1, 'Gwei'), '1000000000');
assert.equal(utils.toWei(1, 'shannon'), '1000000000');
2015-02-23 09:01:00 +00:00
assert.equal(utils.toWei(1, 'szabo'), '1000000000000');
assert.equal(utils.toWei(1, 'finney'), '1000000000000000');
assert.equal(utils.toWei(1, 'ether'), '1000000000000000000');
assert.equal(utils.toWei(1, 'kether'), '1000000000000000000000');
assert.equal(utils.toWei(1, 'grand'), '1000000000000000000000');
assert.equal(utils.toWei(1, 'mether'), '1000000000000000000000000');
assert.equal(utils.toWei(1, 'gether'), '1000000000000000000000000000');
assert.equal(utils.toWei(1, 'tether'), '1000000000000000000000000000000');
2015-03-08 09:07:32 +00:00
assert.equal(utils.toWei(1, 'kwei'), utils.toWei(1, 'femtoether'));
assert.equal(utils.toWei(1, 'szabo'), utils.toWei(1, 'microether'));
2015-05-22 15:04:06 +00:00
assert.equal(utils.toWei(1, 'finney'), utils.toWei(1, 'milliether'));
assert.equal(utils.toWei(1, 'milli'), utils.toWei(1, 'milliether'));
assert.equal(utils.toWei(1, 'milli'), utils.toWei(1000, 'micro'));
2015-03-08 09:07:32 +00:00
assert.throws(function () {utils.toWei(1, 'wei1');}, Error);
});
});
2015-03-08 09:07:32 +00:00
});