File tree 4 files changed +25
-24
lines changed
4 files changed +25
-24
lines changed Original file line number Diff line number Diff line change 3
3
/**
4
4
* Module dependencies.
5
5
*/
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' ) ;
9
10
10
11
/**
11
12
* Test against the given `app`,
@@ -16,7 +17,7 @@ var http = require('http');
16
17
* @api public
17
18
*/
18
19
module . exports = function ( app ) {
19
- var obj = { } ;
20
+ const obj = { } ;
20
21
21
22
if ( typeof app === 'function' ) {
22
23
app = http . createServer ( app ) ; // eslint-disable-line no-param-reassign
@@ -42,4 +43,4 @@ module.exports.Test = Test;
42
43
/**
43
44
* Expose the agent function
44
45
*/
45
- module . exports . agent = require ( './lib/ agent' ) ;
46
+ module . exports . agent = agent ;
Original file line number Diff line number Diff line change 4
4
* Module dependencies.
5
5
*/
6
6
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' ) ;
17
11
18
12
/**
19
13
* Initialize a new `TestAgent`.
@@ -50,7 +44,7 @@ TestAgent.prototype.host = function(host) {
50
44
// override HTTP verb methods
51
45
methods . forEach ( function ( method ) {
52
46
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 ) ;
54
48
req . ca ( this . _ca ) ;
55
49
req . cert ( this . _cert ) ;
56
50
req . key ( this . _key ) ;
@@ -69,3 +63,9 @@ methods.forEach(function(method) {
69
63
} ) ;
70
64
71
65
TestAgent . 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');
10
10
const { deepStrictEqual } = require ( 'assert' ) ;
11
11
const { Request } = require ( 'superagent' ) ;
12
12
13
+ /** @typedef {import('superagent').Response } Response */
14
+
13
15
class Test extends Request {
14
16
/**
15
17
* Initialize a new `Test` with the given `app`,
@@ -111,18 +113,16 @@ class Test extends Request {
111
113
* @api public
112
114
*/
113
115
end ( fn ) {
114
- const self = this ;
115
116
const server = this . _server ;
116
- const end = Request . prototype . end ;
117
117
118
- end . call ( this , function ( err , res ) {
118
+ super . end ( ( err , res ) => {
119
+ const localAssert = ( ) => {
120
+ this . assert ( err , res , fn ) ;
121
+ } ;
122
+
119
123
if ( server && server . _handle ) return server . close ( localAssert ) ;
120
124
121
125
localAssert ( ) ;
122
-
123
- function localAssert ( ) {
124
- self . assert ( err , res , fn ) ;
125
- }
126
126
} ) ;
127
127
128
128
return this ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const request = require ( '..' ) ;
4
3
const https = require ( 'https' ) ;
5
4
const fs = require ( 'fs' ) ;
6
5
const path = require ( 'path' ) ;
@@ -9,6 +8,7 @@ const express = require('express');
9
8
const bodyParser = require ( 'body-parser' ) ;
10
9
const cookieParser = require ( 'cookie-parser' ) ;
11
10
const nock = require ( 'nock' ) ;
11
+ const request = require ( '../index.js' ) ;
12
12
13
13
process . env . NODE_TLS_REJECT_UNAUTHORIZED = '0' ;
14
14
You can’t perform that action at this time.
0 commit comments