UNPKG

785 BJavaScriptView Raw
1'use strict';
2
3/**
4 * Module dependencies.
5 */
6var methods = require('methods');
7var Test = require('./lib/test');
8var 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 */
18module.exports = function(app) {
19 var obj = {};
20
21 if (typeof app === 'function') {
22 app = http.createServer(app); // eslint-disable-line no-param-reassign
23 }
24
25 methods.forEach(function(method) {
26 obj[method] = function(url) {
27 return new Test(app, method, url);
28 };
29 });
30
31 // Support previous use of del
32 obj.del = obj.delete;
33
34 return obj;
35};
36
37/**
38 * Expose `Test`
39 */
40module.exports.Test = Test;
41
42/**
43 * Expose the agent function
44 */
45module.exports.agent = require('./lib/agent');