index.js 720 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Module dependencies.
  3. */
  4. var methods = require('methods')
  5. , Test = require('./lib/test')
  6. , http = require('http');
  7. /**
  8. * Test against the given `app`,
  9. * returning a new `Test`.
  10. *
  11. * @param {Function|Server} app
  12. * @return {Test}
  13. * @api public
  14. */
  15. module.exports = function(app){
  16. if ('function' == typeof app) app = http.createServer(app);
  17. var obj = {};
  18. methods.forEach(function(method){
  19. obj[method] = function(url){
  20. return new Test(app, method, url);
  21. };
  22. });
  23. // Support previous use of del
  24. obj.del = obj['delete'];
  25. return obj;
  26. };
  27. /**
  28. * Expose `Test`
  29. */
  30. module.exports.Test = Test;
  31. /**
  32. * Expose the agent function
  33. */
  34. module.exports.agent = require('./lib/agent');