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.

45 lines
1.4 KiB

8 years ago
  1. var assert = require('assert'),
  2. request = require('request'),
  3. vows = require('vows'),
  4. union = require('../');
  5. vows.describe('union/properties').addBatch({
  6. 'When using `union`': {
  7. 'with a server that responds to requests': {
  8. topic: function () {
  9. var callback = this.callback;
  10. var server = union.createServer({
  11. before: [
  12. function (req, res) {
  13. callback(null, req, res);
  14. res.writeHead(200, { 'content-type': 'text' });
  15. res.end();
  16. }
  17. ]
  18. });
  19. server.listen(9092, function () {
  20. request('http://localhost:9092/');
  21. });
  22. },
  23. 'the `req` should have a proper `httpVersion` set': function (err, req) {
  24. assert.isNull(err);
  25. assert.equal(req.httpVersion, '1.1');
  26. },
  27. 'the `req` should have a proper `httpVersionMajor` set': function (err, req) {
  28. assert.isNull(err);
  29. assert.equal(req.httpVersionMajor, 1);
  30. },
  31. 'the `req` should have a proper `httpVersionMinor` set': function (err, req) {
  32. assert.isNull(err);
  33. assert.equal(req.httpVersionMinor, 1);
  34. },
  35. 'the `req` should have proper `socket` reference set': function (err, req) {
  36. var net = require('net');
  37. assert.isNull(err);
  38. assert.isTrue(req.socket instanceof net.Socket);
  39. }
  40. }
  41. }
  42. }).export(module);