UNPKG

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