File tree Expand file tree Collapse file tree 2 files changed +37
-5
lines changed Expand file tree Collapse file tree 2 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -179,13 +179,18 @@ Node.prototype.getServiceOrder = function() {
179
179
Node . prototype . _startService = function ( serviceInfo , callback ) {
180
180
var self = this ;
181
181
182
- $ . checkState ( _ . isObject ( serviceInfo . config ) ) ;
183
- $ . checkState ( ! serviceInfo . config . node ) ;
184
- $ . checkState ( ! serviceInfo . config . name ) ;
185
-
186
182
log . info ( 'Starting ' + serviceInfo . name ) ;
187
183
188
- var config = serviceInfo . config ;
184
+ var config ;
185
+ if ( serviceInfo . config ) {
186
+ $ . checkState ( _ . isObject ( serviceInfo . config ) ) ;
187
+ $ . checkState ( ! serviceInfo . config . node ) ;
188
+ $ . checkState ( ! serviceInfo . config . name ) ;
189
+ config = serviceInfo . config ;
190
+ } else {
191
+ config = { } ;
192
+ }
193
+
189
194
config . node = this ;
190
195
config . name = serviceInfo . name ;
191
196
var service = new serviceInfo . module ( config ) ;
Original file line number Diff line number Diff line change @@ -233,6 +233,33 @@ describe('Bitcore Node', function() {
233
233
getData . callCount . should . equal ( 1 ) ;
234
234
} ) ;
235
235
} ) ;
236
+ it ( 'will handle config not being set' , function ( ) {
237
+ var node = new Node ( baseConfig ) ;
238
+ function TestService ( ) { }
239
+ util . inherits ( TestService , BaseService ) ;
240
+ TestService . prototype . start = sinon . stub ( ) . callsArg ( 0 ) ;
241
+ var getData = sinon . stub ( ) ;
242
+ TestService . prototype . getData = getData ;
243
+ TestService . prototype . getAPIMethods = function ( ) {
244
+ return [
245
+ [ 'getData' , this , this . getData , 1 ]
246
+ ] ;
247
+ } ;
248
+ var service = {
249
+ name : 'testservice' ,
250
+ module : TestService ,
251
+ } ;
252
+ node . _startService ( service , function ( err ) {
253
+ if ( err ) {
254
+ throw err ;
255
+ }
256
+ TestService . prototype . start . callCount . should . equal ( 1 ) ;
257
+ should . exist ( node . services . testservice ) ;
258
+ should . exist ( node . getData ) ;
259
+ node . getData ( ) ;
260
+ getData . callCount . should . equal ( 1 ) ;
261
+ } ) ;
262
+ } ) ;
236
263
it ( 'will give an error from start' , function ( ) {
237
264
var node = new Node ( baseConfig ) ;
238
265
function TestService ( ) { }
You can’t perform that action at this time.
0 commit comments