You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

8 years ago
  1. var assert = require('assert'),
  2. request = require('request'),
  3. vows = require('vows'),
  4. union = require('../');
  5. vows.describe('union/header').addBatch({
  6. 'When using `union`': {
  7. 'with a server that responds with a header': {
  8. topic: function () {
  9. var callback = this.callback;
  10. var server = union.createServer({
  11. before: [
  12. function (req, res) {
  13. res.on('header', function () {
  14. callback(null, res);
  15. });
  16. res.writeHead(200, { 'content-type': 'text' });
  17. res.end();
  18. }
  19. ]
  20. });
  21. server.listen(9092, function () {
  22. request('http://localhost:9092/');
  23. });
  24. },
  25. 'it should have proper `headerSent` set': function (err, res) {
  26. assert.isNull(err);
  27. assert.isTrue(res.headerSent);
  28. },
  29. 'it should have proper `_emittedHeader` set': function (err, res) {
  30. assert.isNull(err);
  31. assert.isTrue(res._emittedHeader);
  32. }
  33. }
  34. }
  35. }).export(module);