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.

31 lines
852 B

7 years ago
  1. var assert = require('assert'),
  2. request = require('request'),
  3. vows = require('vows'),
  4. union = require('../');
  5. vows.describe('union/status-code').addBatch({
  6. 'When using `union`': {
  7. 'with a server setting `res.statusCode`': {
  8. topic: function () {
  9. var server = union.createServer({
  10. before: [
  11. function (req, res) {
  12. res.statusCode = 404;
  13. res.end();
  14. }
  15. ]
  16. });
  17. server.listen(9091, this.callback);
  18. },
  19. 'and sending a request': {
  20. topic: function () {
  21. request('http://localhost:9091/', this.callback);
  22. },
  23. 'it should have proper `statusCode` set': function (err, res, body) {
  24. assert.isTrue(!err);
  25. assert.equal(res.statusCode, 404);
  26. }
  27. }
  28. }
  29. }
  30. }).export(module);