Fix Hurst fetch URL to use full API_BASE_URL and ensure endpoint returns JSON for all query params
This commit is contained in:
62
node_modules/union/test/double-write-test.js
generated
vendored
Normal file
62
node_modules/union/test/double-write-test.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
request = require('request'),
|
||||
vows = require('vows'),
|
||||
union = require('../lib/index'),
|
||||
macros = require('./helpers/macros');
|
||||
|
||||
var doubleWrite = false,
|
||||
server;
|
||||
|
||||
server = union.createServer({
|
||||
before: [
|
||||
function (req, res) {
|
||||
res.json(200, { 'hello': 'world' });
|
||||
res.emit('next');
|
||||
},
|
||||
function (req, res) {
|
||||
doubleWrite = true;
|
||||
res.json(200, { 'hello': 'world' });
|
||||
res.emit('next');
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
vows.describe('union/double-write').addBatch({
|
||||
"When using union": {
|
||||
"an http server which attempts to write to the response twice": {
|
||||
topic: function () {
|
||||
server.listen(9091, this.callback);
|
||||
},
|
||||
"a GET request to `/foo`": {
|
||||
topic: function () {
|
||||
request({ uri: 'http://localhost:9091/foo' }, this.callback);
|
||||
},
|
||||
"it should respond with `{ 'hello': 'world' }`": function (err, res, body) {
|
||||
macros.assertValidResponse(err, res);
|
||||
assert.deepEqual(JSON.parse(body), { 'hello': 'world' });
|
||||
},
|
||||
"it should not write to the response twice": function () {
|
||||
assert.isFalse(doubleWrite);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).addBatch({
|
||||
"When the tests are over": {
|
||||
"the server should close": function () {
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
|
||||
Reference in New Issue
Block a user