sparc-commons
Advanced tools
Comparing version 0.2.28 to 0.3.0
@@ -34,6 +34,7 @@ /*jshint multistr: true */ | ||
* @param {Object} opts | ||
* @param {String} [opts.rest] the dynamic path added to the URL | ||
* @param {Object} [opts.request] the request options | ||
* @param {Stream} [opts.stream] if this is true, then data is ignored | ||
* @param {Object} [opts.data] key value pairs to be set in the request | ||
* @param {Object} [opts.header] optional header in case of post requests | ||
* @param {Object} [opts.headers] optional header in case of post requests | ||
* @return {Stream<JSON>} | ||
@@ -75,2 +76,6 @@ */ | ||
if(opts.rest){ | ||
url += '/' + opts.rest | ||
} | ||
if (requestStream) { | ||
@@ -77,0 +82,0 @@ // in this case all data options are brutally added to the url. |
{ | ||
"name": "sparc-commons", | ||
"version": "0.2.28", | ||
"version": "0.3.0", | ||
"description": "Library with all small time common stuff used across the SPARC echosystem", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,2 +19,14 @@ var nock = require('nock'); | ||
it("Tests rest", function(){ | ||
nock("http://bogus.com") | ||
.get("/bellobell/pippo,pappo") | ||
.query({apikey: "asdfg", friggitoria: 'cadetta'}) | ||
.reply(200, 'Hallo'); | ||
return requestResource("test_resource", "boguservice", { rest: 'pippo,pappo', query: { friggitoria: 'cadetta' }}) | ||
.then(function(result){ | ||
assert(result, 'Hallo') | ||
}) | ||
}) | ||
it("Tests resource returning an error", function(){ | ||
@@ -21,0 +33,0 @@ nock("http://bogus.com") |
51769
1265