clang
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -10,3 +10,3 @@ var _ = require('lodash'); | ||
} | ||
this.config = _.clone(config); | ||
this.config = _.clone(config || {}); | ||
this.api = null; | ||
@@ -37,13 +37,23 @@ } | ||
var me = this; | ||
var localArgs; | ||
if (!me.config.uuid) { | ||
if (arguments.length === 2) { | ||
callback = args; | ||
localArgs = { | ||
uuid: me.config.uuid | ||
}; | ||
} else if (arguments.length === 3) { | ||
localArgs = _.assign({ | ||
uuid: me.config.uuid | ||
}, args || {}); | ||
} else { | ||
throw new Error('request takes 3 arguments: methodName, args (object) and callback function'); | ||
} | ||
if (!localArgs.uuid) { | ||
return setImmediate(function() { | ||
callback(new Error('uuid missing with client instantiation. Hint: `var clang = new Clang({uuid: \'12345678-...\'})`')); | ||
callback(new Error('uuid missing. Provide it with the 2nd arguments object or with client instantiation. Hint: `var clang = new Clang({uuid: \'12345678-...\'})`')); | ||
}); | ||
} | ||
var localArgs = _.assign({ | ||
uuid: me.config.uuid | ||
}, args || {}); | ||
async.waterfall([ | ||
@@ -50,0 +60,0 @@ function async_init(callback){ |
{ | ||
"name": "clang", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Node.js api wrapper for Clang's SOAP api", | ||
@@ -5,0 +5,0 @@ "author": "Christiaan Westerbeek <chris@devotis.nl>", |
var should = require('should'); | ||
var Clang = require('../index'); | ||
var clang = new Clang(); | ||
describe('Class instantiation', function() { | ||
it('Clang instantiation should work', function() { | ||
var x = new Clang(); | ||
(x instanceof Clang).should.be.equal(true); | ||
(clang instanceof Clang).should.be.equal(true); | ||
}); | ||
@@ -18,1 +18,14 @@ it('Clang instantiation without new keyword should work', function() { | ||
describe('Request signature', function() { | ||
it('Request without methodName and arguments should throw an error', function(done) { | ||
try { | ||
clang.request(function(err, result) { | ||
false.should.be.equal(false); | ||
done(); | ||
}); | ||
} catch(e) { | ||
true.should.be.equal(true); | ||
done(); | ||
} | ||
}); | ||
}); |
223416
6490