2015-03-22 17:12:52 +00:00
|
|
|
var chai = require('chai');
|
|
|
|
var assert = chai.assert;
|
|
|
|
var Method = require('../lib/web3/method');
|
|
|
|
var errors = require('../lib/web3/errors');
|
|
|
|
|
2015-03-25 21:17:35 +00:00
|
|
|
describe('lib/web3/method', function () {
|
2015-03-22 17:12:52 +00:00
|
|
|
describe('validateArgs', function () {
|
|
|
|
it('should pass', function () {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var method = new Method({
|
|
|
|
params: 1
|
|
|
|
});
|
|
|
|
|
|
|
|
var args = [1];
|
|
|
|
var args2 = ['heloas'];
|
|
|
|
|
|
|
|
// when
|
|
|
|
var test = function () { method.validateArgs(args); };
|
|
|
|
var test2 = function () { method.validateArgs(args2); };
|
|
|
|
|
|
|
|
// then
|
|
|
|
assert.doesNotThrow(test);
|
|
|
|
assert.doesNotThrow(test2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return call based on args', function () {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var method = new Method({
|
|
|
|
params: 2
|
|
|
|
});
|
|
|
|
|
|
|
|
var args = [1];
|
|
|
|
var args2 = ['heloas', '12', 3];
|
|
|
|
|
|
|
|
// when
|
|
|
|
var test = function () { method.validateArgs(args); };
|
|
|
|
var test2 = function () { method.validateArgs(args2); };
|
|
|
|
|
|
|
|
// then
|
2015-04-16 09:11:33 +00:00
|
|
|
assert.throws(test, errors.InvalidNumberOfParams().message);
|
|
|
|
assert.throws(test2, errors.InvalidNumberOfParams().message);
|
2015-03-22 17:12:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|