File tree Expand file tree Collapse file tree 4 files changed +25
-24
lines changed
Expand file tree Collapse file tree 4 files changed +25
-24
lines changed Original file line number Diff line number Diff line change 33/**
44 * Module dependencies.
55 */
6- var methods = require ( 'methods' ) ;
7- var Test = require ( './lib/test' ) ;
8- var http = require ( 'http' ) ;
6+ const methods = require ( 'methods' ) ;
7+ const http = require ( 'http' ) ;
8+ const Test = require ( './lib/test.js' ) ;
9+ const agent = require ( './lib/agent.js' ) ;
910
1011/**
1112 * Test against the given `app`,
@@ -16,7 +17,7 @@ var http = require('http');
1617 * @api public
1718 */
1819module . exports = function ( app ) {
19- var obj = { } ;
20+ const obj = { } ;
2021
2122 if ( typeof app === 'function' ) {
2223 app = http . createServer ( app ) ; // eslint-disable-line no-param-reassign
@@ -42,4 +43,4 @@ module.exports.Test = Test;
4243/**
4344 * Expose the agent function
4445 */
45- module . exports . agent = require ( './lib/ agent' ) ;
46+ module . exports . agent = agent ;
Original file line number Diff line number Diff line change 44 * Module dependencies.
55 */
66
7- var Agent = require ( 'superagent' ) . agent ;
8- var methods = require ( 'methods' ) ;
9- var http = require ( 'http' ) ;
10- var Test = require ( './test' ) ;
11-
12- /**
13- * Expose `Agent`.
14- */
15-
16- module . exports = TestAgent ;
7+ const { agent : Agent } = require ( 'superagent' ) ;
8+ const methods = require ( 'methods' ) ;
9+ const http = require ( 'http' ) ;
10+ const Test = require ( './test.js' ) ;
1711
1812/**
1913 * Initialize a new `TestAgent`.
@@ -50,7 +44,7 @@ TestAgent.prototype.host = function(host) {
5044// override HTTP verb methods
5145methods . forEach ( function ( method ) {
5246 TestAgent . prototype [ method ] = function ( url , fn ) { // eslint-disable-line no-unused-vars
53- var req = new Test ( this . app , method . toUpperCase ( ) , url , this . _host ) ;
47+ const req = new Test ( this . app , method . toUpperCase ( ) , url , this . _host ) ;
5448 req . ca ( this . _ca ) ;
5549 req . cert ( this . _cert ) ;
5650 req . key ( this . _key ) ;
@@ -69,3 +63,9 @@ methods.forEach(function(method) {
6963} ) ;
7064
7165TestAgent . prototype . del = TestAgent . prototype . delete ;
66+
67+ /**
68+ * Expose `Agent`.
69+ */
70+
71+ module . exports = TestAgent ;
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ const { Server } = require('https');
1010const { deepStrictEqual } = require ( 'assert' ) ;
1111const { Request } = require ( 'superagent' ) ;
1212
13+ /** @typedef {import('superagent').Response } Response */
14+
1315class Test extends Request {
1416 /**
1517 * Initialize a new `Test` with the given `app`,
@@ -111,18 +113,16 @@ class Test extends Request {
111113 * @api public
112114 */
113115 end ( fn ) {
114- const self = this ;
115116 const server = this . _server ;
116- const end = Request . prototype . end ;
117117
118- end . call ( this , function ( err , res ) {
118+ super . end ( ( err , res ) => {
119+ const localAssert = ( ) => {
120+ this . assert ( err , res , fn ) ;
121+ } ;
122+
119123 if ( server && server . _handle ) return server . close ( localAssert ) ;
120124
121125 localAssert ( ) ;
122-
123- function localAssert ( ) {
124- self . assert ( err , res , fn ) ;
125- }
126126 } ) ;
127127
128128 return this ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const request = require ( '..' ) ;
43const https = require ( 'https' ) ;
54const fs = require ( 'fs' ) ;
65const path = require ( 'path' ) ;
@@ -9,6 +8,7 @@ const express = require('express');
98const bodyParser = require ( 'body-parser' ) ;
109const cookieParser = require ( 'cookie-parser' ) ;
1110const nock = require ( 'nock' ) ;
11+ const request = require ( '../index.js' ) ;
1212
1313process . env . NODE_TLS_REJECT_UNAUTHORIZED = '0' ;
1414
You can’t perform that action at this time.
0 commit comments