Fix Hurst fetch URL to use full API_BASE_URL and ensure endpoint returns JSON for all query params
This commit is contained in:
50
node_modules/union/test/body-parser-test.js
generated
vendored
Normal file
50
node_modules/union/test/body-parser-test.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* simple-test.js: Simple tests for basic streaming and non-streaming HTTP requests with union.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins & the Contributors
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
connect = require('connect'),
|
||||
request = require('request'),
|
||||
vows = require('vows'),
|
||||
union = require('../');
|
||||
|
||||
vows.describe('union/body-parser').addBatch({
|
||||
"When using union with connect body parsing via urlencoded() or json()": {
|
||||
topic: function () {
|
||||
union.createServer({
|
||||
buffer: false,
|
||||
before: [
|
||||
connect.urlencoded(),
|
||||
connect.json(),
|
||||
function (req, res) {
|
||||
res.end(JSON.stringify(req.body, true, 2));
|
||||
}
|
||||
]
|
||||
}).listen(8082, this.callback);
|
||||
},
|
||||
"a request to /": {
|
||||
topic: function () {
|
||||
request.post({
|
||||
uri: 'http://localhost:8082/',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ a: "foo", b: "bar" })
|
||||
}, this.callback);
|
||||
},
|
||||
"should respond with a body-decoded object": function (err, res, body) {
|
||||
assert.isNull(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.deepEqual(
|
||||
JSON.parse(body),
|
||||
{ a: 'foo', b: 'bar' }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
|
||||
Reference in New Issue
Block a user