Skip to content

Commit

Permalink
[test] check headerSent and _emittedHeader are set in response st…
Browse files Browse the repository at this point in the history
…ream
  • Loading branch information
fent committed Feb 12, 2013
1 parent 16c9a0b commit afd2ccb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/header-test.js
@@ -0,0 +1,36 @@
var assert = require('assert'),
request = require('request'),
vows = require('vows'),
union = require('../');

vows.describe('union/header').addBatch({
'When using `union`': {
'with a server that responds with a header': {
topic: function () {
var callback = this.callback;
var server = union.createServer({
before: [
function (req, res) {
res.on('header', function() {
callback(null, res);
});
res.writeHead(200, { 'content-type': 'text' });
res.end();
}
]
});
server.listen(9092, function() {
request('http://localhost:9092/');
});
},
'it should have proper `headerSent` set': function (err, res) {
assert.isNull(err);
assert.isTrue(res.headerSent);
},
'it should have proper `_emittedHeader` set': function (err, res) {
assert.isNull(err);
assert.isTrue(res._emittedHeader);
}
}
}
}).export(module);

0 comments on commit afd2ccb

Please sign in to comment.