bitcore-node-zcash/test/scaffold/start.integration.js

82 lines
1.9 KiB
JavaScript
Raw Normal View History

'use strict';
var should = require('chai').should();
var sinon = require('sinon');
2015-08-25 10:57:54 -07:00
var proxyquire = require('proxyquire');
2015-08-31 06:00:00 -07:00
var AddressService = require('../../lib/services/address');
describe('#start', function() {
describe('will dynamically create a node from a configuration', function() {
2015-08-31 10:37:11 -07:00
it('require each bitcore-node service with default config', function(done) {
2015-08-25 10:57:54 -07:00
var node;
var TestNode = function(options) {
2015-08-31 06:00:00 -07:00
options.services[0].should.deep.equal({
2015-08-27 13:09:27 -07:00
name: 'address',
2015-08-31 06:00:00 -07:00
module: AddressService,
2015-08-31 10:37:11 -07:00
config: {}
2015-08-27 13:09:27 -07:00
});
2015-08-25 10:57:54 -07:00
};
TestNode.prototype.on = sinon.stub();
TestNode.prototype.chain = {
on: sinon.stub()
};
var starttest = proxyquire('../../lib/scaffold/start', {
'../node': TestNode
});
node = starttest({
path: __dirname,
config: {
2015-08-31 06:00:00 -07:00
services: [
2015-08-25 10:57:54 -07:00
'address'
],
datadir: './data'
}
});
node.should.be.instanceof(TestNode);
done();
});
2015-08-31 10:37:11 -07:00
it('require each bitcore-node service with explicit config', function(done) {
var node;
var TestNode = function(options) {
options.services[0].should.deep.equal({
name: 'address',
module: AddressService,
config: {
param: 'test'
}
});
};
TestNode.prototype.on = sinon.stub();
TestNode.prototype.chain = {
on: sinon.stub()
};
var starttest = proxyquire('../../lib/scaffold/start', {
'../node': TestNode
});
node = starttest({
path: __dirname,
config: {
services: [
2015-08-31 10:38:21 -07:00
'address'
2015-08-31 10:37:11 -07:00
],
2015-08-31 10:38:21 -07:00
servicesConfig: {
'address': {
param: 'test'
}
},
2015-08-31 10:37:11 -07:00
datadir: './data'
}
});
node.should.be.instanceof(TestNode);
done();
});
});
});