UNPKG

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