web3.js/test/formatters.inputAddressForm...

42 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-08-08 18:34:12 +00:00
var chai = require('chai');
var assert = chai.assert;
var formatters = require('../lib/web3/formatters.js');
var BigNumber = require('bignumber.js');
var tests = [{
input: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
input: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
input: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8'
}];
var errorTests = [
'0x0c5496aee77c1ba1f0854206a26dda82a81d6d8',
'0x0c5496aee77c1ba1f0854206a26dda82a81d6d8',
'00c5496aee77c1ba1f0854206a26dda82a81d6d',
'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZE',
'0x'
]
describe('formatters', function () {
describe('inputAddressFormatter', function () {
tests.forEach(function(test){
it('should return the correct value', function () {
assert.deepEqual(formatters.inputAddressFormatter(test.input), test.result);
});
});
});
});
describe('formatters', function () {
describe('inputAddressFormatter', function () {
errorTests.forEach(function(test){
it('should throw an exception', function () {
assert.throws(function () {
formatters.inputAddressFormatter(test);
});
});
});
});
});