Update unit tests with node.modules as an object.
This commit is contained in:
parent
56ebf42403
commit
1ed457504c
@ -20,7 +20,6 @@ describe('Bitcoin DB', function() {
|
|||||||
describe('#start', function() {
|
describe('#start', function() {
|
||||||
it('should emit ready', function(done) {
|
it('should emit ready', function(done) {
|
||||||
var db = new DB({store: memdown});
|
var db = new DB({store: memdown});
|
||||||
db._modules = ['mod1', 'mod2'];
|
|
||||||
db.node = {};
|
db.node = {};
|
||||||
db.node.bitcoind = {
|
db.node.bitcoind = {
|
||||||
on: sinon.spy()
|
on: sinon.spy()
|
||||||
@ -336,10 +335,10 @@ describe('Bitcoin DB', function() {
|
|||||||
var Module2 = function() {};
|
var Module2 = function() {};
|
||||||
Module2.prototype.blockHandler = sinon.stub().callsArgWith(2, null, ['op4', 'op5']);
|
Module2.prototype.blockHandler = sinon.stub().callsArgWith(2, null, ['op4', 'op5']);
|
||||||
db.node = {};
|
db.node = {};
|
||||||
db.node.modules = [
|
db.node.modules = {
|
||||||
new Module1(),
|
module1: new Module1(),
|
||||||
new Module2()
|
module2: new Module2()
|
||||||
];
|
};
|
||||||
db.store = {
|
db.store = {
|
||||||
batch: sinon.stub().callsArg(1)
|
batch: sinon.stub().callsArg(1)
|
||||||
};
|
};
|
||||||
@ -355,7 +354,7 @@ describe('Bitcoin DB', function() {
|
|||||||
it('should give an error if one of the modules gives an error', function(done) {
|
it('should give an error if one of the modules gives an error', function(done) {
|
||||||
var Module3 = function() {};
|
var Module3 = function() {};
|
||||||
Module3.prototype.blockHandler = sinon.stub().callsArgWith(2, new Error('error'));
|
Module3.prototype.blockHandler = sinon.stub().callsArgWith(2, new Error('error'));
|
||||||
db.node.modules.push(new Module3());
|
db.node.modules.module3 = new Module3();
|
||||||
|
|
||||||
db.blockHandler('block', true, function(err) {
|
db.blockHandler('block', true, function(err) {
|
||||||
should.exist(err);
|
should.exist(err);
|
||||||
@ -368,7 +367,7 @@ describe('Bitcoin DB', function() {
|
|||||||
it('should return the correct db methods', function() {
|
it('should return the correct db methods', function() {
|
||||||
var db = new DB({store: memdown});
|
var db = new DB({store: memdown});
|
||||||
db.node = {};
|
db.node = {};
|
||||||
db.node.modules = [];
|
db.node.modules = {};
|
||||||
var methods = db.getAPIMethods();
|
var methods = db.getAPIMethods();
|
||||||
methods.length.should.equal(4);
|
methods.length.should.equal(4);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -113,14 +113,14 @@ describe('Bitcore Node', function() {
|
|||||||
describe('#getAllAPIMethods', function() {
|
describe('#getAllAPIMethods', function() {
|
||||||
it('should return db methods and modules methods', function() {
|
it('should return db methods and modules methods', function() {
|
||||||
var node = new Node({});
|
var node = new Node({});
|
||||||
node.modules = [
|
node.modules = {
|
||||||
{
|
module1: {
|
||||||
getAPIMethods: sinon.stub().returns(['mda1', 'mda2'])
|
getAPIMethods: sinon.stub().returns(['mda1', 'mda2'])
|
||||||
},
|
},
|
||||||
{
|
module2: {
|
||||||
getAPIMethods: sinon.stub().returns(['mdb1', 'mdb2'])
|
getAPIMethods: sinon.stub().returns(['mdb1', 'mdb2'])
|
||||||
}
|
}
|
||||||
];
|
};
|
||||||
var db = {
|
var db = {
|
||||||
getAPIMethods: sinon.stub().returns(['db1', 'db2']),
|
getAPIMethods: sinon.stub().returns(['db1', 'db2']),
|
||||||
};
|
};
|
||||||
@ -133,14 +133,14 @@ describe('Bitcore Node', function() {
|
|||||||
describe('#getAllPublishEvents', function() {
|
describe('#getAllPublishEvents', function() {
|
||||||
it('should return modules publish events', function() {
|
it('should return modules publish events', function() {
|
||||||
var node = new Node({});
|
var node = new Node({});
|
||||||
node.modules = [
|
node.modules = {
|
||||||
{
|
module1: {
|
||||||
getPublishEvents: sinon.stub().returns(['mda1', 'mda2'])
|
getPublishEvents: sinon.stub().returns(['mda1', 'mda2'])
|
||||||
},
|
},
|
||||||
{
|
module2: {
|
||||||
getPublishEvents: sinon.stub().returns(['mdb1', 'mdb2'])
|
getPublishEvents: sinon.stub().returns(['mdb1', 'mdb2'])
|
||||||
}
|
}
|
||||||
];
|
};
|
||||||
var db = {
|
var db = {
|
||||||
getPublishEvents: sinon.stub().returns(['db1', 'db2']),
|
getPublishEvents: sinon.stub().returns(['db1', 'db2']),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user