File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,32 @@ describe('app.listen()', function(){
2424 } )
2525 } )
2626 } )
27+ it ( 'accepts port + hostname + backlog + callback' , function ( done ) {
28+ const app = express ( ) ;
29+ const server = app . listen ( 0 , '127.0.0.1' , 5 , function ( ) {
30+ const { address, port } = server . address ( ) ;
31+ assert . strictEqual ( address , '127.0.0.1' ) ;
32+ assert ( Number . isInteger ( port ) && port > 0 ) ;
33+ // backlog isn’t directly inspectable, but if no error was thrown
34+ // we know it was accepted.
35+ server . close ( done ) ;
36+ } ) ;
37+ } ) ;
38+ it ( 'accepts just a callback (no args)' , function ( done ) {
39+ const app = express ( ) ;
40+ // same as app.listen(0, done)
41+ const server = app . listen ( ) ;
42+ server . close ( done ) ;
43+ } ) ;
44+ it ( 'server.address() gives a { address, port, family } object' , function ( done ) {
45+ const app = express ( ) ;
46+ const server = app . listen ( 0 , ( ) => {
47+ const addr = server . address ( ) ;
48+ assert ( addr && typeof addr === 'object' ) ;
49+ assert . strictEqual ( typeof addr . address , 'string' ) ;
50+ assert ( Number . isInteger ( addr . port ) && addr . port > 0 ) ;
51+ assert ( typeof addr . family === 'string' ) ;
52+ server . close ( done ) ;
53+ } ) ;
54+ } ) ;
2755} )
You can’t perform that action at this time.
0 commit comments