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() {
|
||||
it('should emit ready', function(done) {
|
||||
var db = new DB({store: memdown});
|
||||
db._modules = ['mod1', 'mod2'];
|
||||
db.node = {};
|
||||
db.node.bitcoind = {
|
||||
on: sinon.spy()
|
||||
@ -336,10 +335,10 @@ describe('Bitcoin DB', function() {
|
||||
var Module2 = function() {};
|
||||
Module2.prototype.blockHandler = sinon.stub().callsArgWith(2, null, ['op4', 'op5']);
|
||||
db.node = {};
|
||||
db.node.modules = [
|
||||
new Module1(),
|
||||
new Module2()
|
||||
];
|
||||
db.node.modules = {
|
||||
module1: new Module1(),
|
||||
module2: new Module2()
|
||||
};
|
||||
db.store = {
|
||||
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) {
|
||||
var Module3 = function() {};
|
||||
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) {
|
||||
should.exist(err);
|
||||
@ -368,7 +367,7 @@ describe('Bitcoin DB', function() {
|
||||
it('should return the correct db methods', function() {
|
||||
var db = new DB({store: memdown});
|
||||
db.node = {};
|
||||
db.node.modules = [];
|
||||
db.node.modules = {};
|
||||
var methods = db.getAPIMethods();
|
||||
methods.length.should.equal(4);
|
||||
});
|
||||
|
||||
@ -113,14 +113,14 @@ describe('Bitcore Node', function() {
|
||||
describe('#getAllAPIMethods', function() {
|
||||
it('should return db methods and modules methods', function() {
|
||||
var node = new Node({});
|
||||
node.modules = [
|
||||
{
|
||||
node.modules = {
|
||||
module1: {
|
||||
getAPIMethods: sinon.stub().returns(['mda1', 'mda2'])
|
||||
},
|
||||
{
|
||||
module2: {
|
||||
getAPIMethods: sinon.stub().returns(['mdb1', 'mdb2'])
|
||||
}
|
||||
];
|
||||
};
|
||||
var db = {
|
||||
getAPIMethods: sinon.stub().returns(['db1', 'db2']),
|
||||
};
|
||||
@ -133,14 +133,14 @@ describe('Bitcore Node', function() {
|
||||
describe('#getAllPublishEvents', function() {
|
||||
it('should return modules publish events', function() {
|
||||
var node = new Node({});
|
||||
node.modules = [
|
||||
{
|
||||
node.modules = {
|
||||
module1: {
|
||||
getPublishEvents: sinon.stub().returns(['mda1', 'mda2'])
|
||||
},
|
||||
{
|
||||
module2: {
|
||||
getPublishEvents: sinon.stub().returns(['mdb1', 'mdb2'])
|
||||
}
|
||||
];
|
||||
};
|
||||
var db = {
|
||||
getPublishEvents: sinon.stub().returns(['db1', 'db2']),
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user