flocore-node/test/scaffold/default-config.integration.js
Braydon Fuller e046f7294e Changes to be able to run with only a configuration file.
- Adds parameter to cli methods to be able to specify the location of services modules. This is useful for packages that wrap bitcore-node to be able to pass along a node_modules directory with services.
- Adds another parameter for including additional services in the default settings.
- Will use the `process.env.HOME + '/.bitcore` as the default configuration location.
- There are now two `getDefaultConfig`, one that will instatiate a `~/.bitcore` directory with a default if it doesn't exist, and `getBaseDefaultConfig` that will return a basic configuration without additional services enabled.
- Changes logic to use the global install if a local node_modules version is not available, this would previously assume that it was a local install because of the existence of a configuration file.
2015-10-20 12:33:53 -04:00

91 lines
2.5 KiB
JavaScript

'use strict';
var should = require('chai').should();
var sinon = require('sinon');
var proxyquire = require('proxyquire');
describe('#defaultConfig', function() {
it('will return expected configuration', function() {
var config = JSON.stringify({
datadir: process.env.HOME + '/.bitcore/data',
network: 'livenet',
port: 3001,
services: [
'bitcoind',
'db',
'address',
'web'
]
}, null, 2);
var defaultConfig = proxyquire('../../lib/scaffold/default-config', {
fs: {
existsSync: sinon.stub().returns(false),
writeFileSync: function(path, data) {
path.should.equal(process.env.HOME + '/.bitcore/bitcore-node.json');
data.should.equal(config);
},
readFileSync: function() {
return config;
}
},
mkdirp: {
sync: sinon.stub()
}
});
var cwd = process.cwd();
var home = process.env.HOME;
var info = defaultConfig();
info.path.should.equal(home + '/.bitcore');
info.config.datadir.should.equal(home + '/.bitcore/data');
info.config.network.should.equal('livenet');
info.config.port.should.equal(3001);
info.config.services.should.deep.equal(['bitcoind', 'db', 'address', 'web']);
});
it('will include additional services', function() {
var config = JSON.stringify({
datadir: process.env.HOME + '/.bitcore/data',
network: 'livenet',
port: 3001,
services: [
'bitcoind',
'db',
'address',
'web',
'insight-api',
'insight-ui'
]
}, null, 2);
var defaultConfig = proxyquire('../../lib/scaffold/default-config', {
fs: {
existsSync: sinon.stub().returns(false),
writeFileSync: function(path, data) {
path.should.equal(process.env.HOME + '/.bitcore/bitcore-node.json');
data.should.equal(config);
},
readFileSync: function() {
return config;
}
},
mkdirp: {
sync: sinon.stub()
}
});
var home = process.env.HOME;
var info = defaultConfig({
additionalServices: ['insight-api', 'insight-ui']
});
info.path.should.equal(home + '/.bitcore');
info.config.datadir.should.equal(home + '/.bitcore/data');
info.config.network.should.equal('livenet');
info.config.port.should.equal(3001);
info.config.services.should.deep.equal([
'bitcoind',
'db',
'address',
'web',
'insight-api',
'insight-ui'
]);
});
});