web3.js/test/web3.eth.accounts.js

40 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2015-03-23 17:50:33 +00:00
var chai = require('chai');
var assert = chai.assert;
2015-10-07 03:10:02 +00:00
var Web3 = require('../index');
var web3 = new Web3();
2015-03-23 17:50:33 +00:00
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
var method = 'accounts';
var tests = [{
result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'],
formattedResult: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'],
call: 'eth_'+ method
}];
2015-03-25 22:50:39 +00:00
describe('web3.eth', function () {
2015-03-23 17:50:33 +00:00
describe(method, function () {
tests.forEach(function (test, index) {
it('property test: ' + index, function () {
// given
var provider = new FakeHttpProvider();
web3.setProvider(provider);
provider.injectResult(test.result);
provider.injectValidation(function (payload) {
assert.equal(payload.jsonrpc, '2.0');
assert.equal(payload.method, test.call);
assert.deepEqual(payload.params, []);
});
// when
var result = web3.eth[method];
// then
assert.deepEqual(test.formattedResult, result);
});
});
});
});