web3.js/test/method.formatInput.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-03-22 18:48:25 +00:00
var chai = require('chai');
var assert = chai.assert;
var Method = require('../lib/web3/method');
2015-03-25 21:17:35 +00:00
describe('lib/web3/method', function () {
2015-03-22 18:48:25 +00:00
describe('formatInput', function () {
it('should format plain input', function () {
// given
2015-03-23 12:42:36 +00:00
var star = function (arg) {
return arg + '*';
2015-03-22 18:48:25 +00:00
};
var method = new Method({
2015-03-23 12:42:36 +00:00
inputFormatter: [star, star, star]
2015-03-22 18:48:25 +00:00
});
var args = ['1','2','3'];
var expectedArgs = ['1*', '2*', '3*'];
// when
var result = method.formatInput(args);
// then
assert.deepEqual(result, expectedArgs);
});
it('should do nothing if there is no formatter', function () {
// given
var method = new Method({});
var args = [1,2,3];
// when
var result = method.formatInput(args);
// then
assert.deepEqual(result, args);
});
});
});