Browse files

[test] check `headerSent` and `_emittedHeader` are set in response st…

…ream
  • Loading branch information...
1 parent 16c9a0b commit afd2ccb4f468ececb689ec7a72ea46e2fc14e9b8 @fent fent committed Feb 12, 2013
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/header-test.js
View
36 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.