1
- import { RFC8252HTTPServer } from './rfc-8252-http-server' ;
1
+ import { getAllInterfaces , RFC8252HTTPServer } from './rfc-8252-http-server' ;
2
2
import { expect } from 'chai' ;
3
3
import type { Server as HTTPServer } from 'http' ;
4
4
import { createServer as createHTTPServer } from 'http' ;
@@ -487,27 +487,21 @@ describe('RFC8252HTTPServer', function () {
487
487
} ) ;
488
488
} ) ;
489
489
490
- context ( 'with dns duplicates ' , function ( ) {
490
+ context ( 'getAllInterfaces ' , function ( ) {
491
491
let dnsLookupStub : sinon . SinonStub ;
492
- const _getAllInterfaces = RFC8252HTTPServer [ '_getAllInterfaces' ] ;
493
-
494
492
this . beforeEach ( function ( ) {
495
- dnsLookupStub = sinon . stub ( dns , 'lookup' ) ;
496
- } ) ;
497
-
498
- this . afterEach ( function ( ) {
499
- sinon . restore ( ) ;
493
+ dnsLookupStub = sinon . stub ( ) ;
500
494
} ) ;
501
495
502
- it ( 'only filters exact duplicates' , async function ( ) {
496
+ it ( 'filters out exact duplicates' , async function ( ) {
503
497
dnsLookupStub . resolves ( [
504
498
{ address : '127.0.0.1' , family : 4 } ,
505
499
{ address : '127.0.0.1' , family : 4 } ,
506
500
{ address : '[::1]' , family : 6 } ,
507
501
{ address : '[::1]' , family : 6 } ,
508
502
] ) ;
509
503
510
- const interfaces = await _getAllInterfaces ( 'localhost' ) ;
504
+ const interfaces = await getAllInterfaces ( 'localhost' , dnsLookupStub ) ;
511
505
512
506
expect ( interfaces ) . to . have . lengthOf ( 2 ) ;
513
507
expect ( interfaces [ 0 ] . address ) . to . equal ( '127.0.0.1' ) ;
@@ -522,7 +516,7 @@ describe('RFC8252HTTPServer', function () {
522
516
{ address : '127.0.0.1' , family : 6 } ,
523
517
] ) ;
524
518
525
- const interfaces = await _getAllInterfaces ( 'localhost' ) ;
519
+ const interfaces = await getAllInterfaces ( 'localhost' , dnsLookupStub ) ;
526
520
527
521
expect ( interfaces ) . to . have . lengthOf ( 2 ) ;
528
522
expect ( interfaces [ 0 ] . address ) . to . equal ( '127.0.0.1' ) ;
@@ -537,7 +531,7 @@ describe('RFC8252HTTPServer', function () {
537
531
{ address : '192.168.1.15' , family : 4 } ,
538
532
] ) ;
539
533
540
- const interfaces = await _getAllInterfaces ( 'localhost' ) ;
534
+ const interfaces = await getAllInterfaces ( 'localhost' , dnsLookupStub ) ;
541
535
542
536
expect ( interfaces ) . to . have . lengthOf ( 2 ) ;
543
537
expect ( interfaces [ 0 ] . address ) . to . equal ( '127.0.0.1' ) ;
0 commit comments