methodExists and propertyExists are now separated tests

This commit is contained in:
Marek Kotewicz 2015-01-15 11:38:21 +01:00
parent 472ad43211
commit bacc5aa6d3
5 changed files with 45 additions and 51 deletions

View File

@ -7,12 +7,10 @@ web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080'));
describe('web3', function() { describe('web3', function() {
describe('db', function() { describe('db', function() {
it('should have all methods implemented', function() { u.methodExists(web3.db, 'put');
u.methodExists(web3.db, 'put'); u.methodExists(web3.db, 'get');
u.methodExists(web3.db, 'get'); u.methodExists(web3.db, 'putString');
u.methodExists(web3.db, 'putString'); u.methodExists(web3.db, 'getString');
u.methodExists(web3.db, 'getString');
});
}); });
}); });

View File

@ -7,35 +7,31 @@ web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080'));
describe('web3', function() { describe('web3', function() {
describe('eth', function() { describe('eth', function() {
it('should have all methods implemented', function() { u.methodExists(web3.eth, 'balanceAt');
u.methodExists(web3.eth, 'balanceAt'); u.methodExists(web3.eth, 'stateAt');
u.methodExists(web3.eth, 'stateAt'); u.methodExists(web3.eth, 'storageAt');
u.methodExists(web3.eth, 'storageAt'); u.methodExists(web3.eth, 'countAt');
u.methodExists(web3.eth, 'countAt'); u.methodExists(web3.eth, 'codeAt');
u.methodExists(web3.eth, 'codeAt'); u.methodExists(web3.eth, 'transact');
u.methodExists(web3.eth, 'transact'); u.methodExists(web3.eth, 'call');
u.methodExists(web3.eth, 'call'); u.methodExists(web3.eth, 'block');
u.methodExists(web3.eth, 'block'); u.methodExists(web3.eth, 'transaction');
u.methodExists(web3.eth, 'transaction'); u.methodExists(web3.eth, 'uncle');
u.methodExists(web3.eth, 'uncle'); u.methodExists(web3.eth, 'compilers');
u.methodExists(web3.eth, 'compilers'); u.methodExists(web3.eth, 'lll');
u.methodExists(web3.eth, 'lll'); u.methodExists(web3.eth, 'solidity');
u.methodExists(web3.eth, 'solidity'); u.methodExists(web3.eth, 'serpent');
u.methodExists(web3.eth, 'serpent'); u.methodExists(web3.eth, 'logs');
u.methodExists(web3.eth, 'logs');
});
it('should have all properties implemented', function () { u.propertyExists(web3.eth, 'coinbase');
u.propertyExists(web3.eth, 'coinbase'); u.propertyExists(web3.eth, 'listening');
u.propertyExists(web3.eth, 'listening'); u.propertyExists(web3.eth, 'mining');
u.propertyExists(web3.eth, 'mining'); u.propertyExists(web3.eth, 'gasPrice');
u.propertyExists(web3.eth, 'gasPrice'); u.propertyExists(web3.eth, 'account');
u.propertyExists(web3.eth, 'account'); u.propertyExists(web3.eth, 'accounts');
u.propertyExists(web3.eth, 'accounts'); u.propertyExists(web3.eth, 'peerCount');
u.propertyExists(web3.eth, 'peerCount'); u.propertyExists(web3.eth, 'defaultBlock');
u.propertyExists(web3.eth, 'defaultBlock'); u.propertyExists(web3.eth, 'number');
u.propertyExists(web3.eth, 'number');
});
}); });
}); });

View File

@ -7,13 +7,11 @@ web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080'));
describe('web3', function() { describe('web3', function() {
describe('shh', function() { describe('shh', function() {
it('should have all methods implemented', function() { u.methodExists(web3.shh, 'post');
u.methodExists(web3.shh, 'post'); u.methodExists(web3.shh, 'newIdentity');
u.methodExists(web3.shh, 'newIdentity'); u.methodExists(web3.shh, 'haveIdentity');
u.methodExists(web3.shh, 'haveIdentity'); u.methodExists(web3.shh, 'newGroup');
u.methodExists(web3.shh, 'newGroup'); u.methodExists(web3.shh, 'addToGroup');
u.methodExists(web3.shh, 'addToGroup');
});
}); });
}); });

View File

@ -1,11 +1,15 @@
var assert = require('assert'); var assert = require('assert');
var methodExists = function (object, method) { var methodExists = function (object, method) {
assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented'); it('should have method ' + method + ' implemented', function() {
assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented');
});
}; };
var propertyExists = function (object, property) { var propertyExists = function (object, property) {
assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented'); it('should have property ' + property + ' implemented', function() {
assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented');
});
}; };
module.exports = { module.exports = {

View File

@ -6,13 +6,11 @@ var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() { describe('web3', function() {
it('should have all methods implemented', function() { u.methodExists(web3, 'sha3');
u.methodExists(web3, 'sha3'); u.methodExists(web3, 'toAscii');
u.methodExists(web3, 'toAscii'); u.methodExists(web3, 'fromAscii');
u.methodExists(web3, 'fromAscii'); u.methodExists(web3, 'toFixed');
u.methodExists(web3, 'toFixed'); u.methodExists(web3, 'fromFixed');
u.methodExists(web3, 'fromFixed'); u.methodExists(web3, 'offset');
u.methodExists(web3, 'offset');
});
}); });