File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const fs = require('fs');
17
17
const path = require ( 'path' ) ;
18
18
const stream = require ( 'stream' ) ;
19
19
const { parse : parseURL , URLSearchParams } = require ( 'url' ) ;
20
+ const { lookup } = require ( 'dns' ) ;
20
21
21
22
let convert ;
22
23
try { convert = require ( 'encoding' ) . convert ; } catch ( e ) { }
@@ -1531,6 +1532,19 @@ describe('node-fetch', () => {
1531
1532
. and . have . property ( 'message' ) . that . includes ( 'Could not create Buffer' )
1532
1533
. and . that . includes ( 'embedded error' ) ;
1533
1534
} ) ;
1535
+
1536
+ it ( "supports supplying a lookup function to the agent" , function ( ) {
1537
+ const url = `${ base } redirect/301` ;
1538
+ let called = 0 ;
1539
+ function lookupSpy ( hostname , options , callback ) {
1540
+ called ++ ;
1541
+ return lookup ( hostname , options , callback ) ;
1542
+ }
1543
+ const agent = http . Agent ( { lookup : lookupSpy } ) ;
1544
+ return fetch ( url , { agent } ) . then ( ( ) => {
1545
+ expect ( called ) . to . equal ( 2 ) ;
1546
+ } ) ;
1547
+ } ) ;
1534
1548
} ) ;
1535
1549
1536
1550
describe ( 'Headers' , function ( ) {
You can’t perform that action at this time.
0 commit comments