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.

44 lines
1.2 KiB

7 years ago
  1. /*
  2. * simple-test.js: Simple tests for basic streaming and non-streaming HTTP requests with union.
  3. *
  4. * (C) 2011, Charlie Robbins & the Contributors
  5. * MIT LICENSE
  6. *
  7. */
  8. var assert = require('assert'),
  9. ecstatic = require('ecstatic')(__dirname + '/fixtures/static'),
  10. request = require('request'),
  11. vows = require('vows'),
  12. union = require('../');
  13. vows.describe('union/ecstatic').addBatch({
  14. "When using union with ecstatic": {
  15. topic: function () {
  16. union.createServer({
  17. before: [
  18. ecstatic
  19. ]
  20. }).listen(18082, this.callback);
  21. },
  22. "a request to /some-file.txt": {
  23. topic: function () {
  24. request({ uri: 'http://localhost:18082/some-file.txt' }, this.callback);
  25. },
  26. "should respond with `hello world`": function (err, res, body) {
  27. assert.isNull(err);
  28. assert.equal(body, 'hello world\n');
  29. }
  30. },
  31. "a request to /404.txt (which does not exist)": {
  32. topic: function () {
  33. request({ uri: 'http://localhost:18082/404.txt' }, this.callback);
  34. },
  35. "should respond with 404 status code": function (err, res, body) {
  36. assert.isNull(err);
  37. assert.equal(res.statusCode, 404);
  38. }
  39. }
  40. }
  41. }).export(module);