1- const PORT = 4443
1+ const HTTPS_PORT = 4443
2+ const HTTP_PORT = 8080
23
34const assert = require ( "assert" )
45const fs = require ( "fs" )
@@ -7,7 +8,7 @@ const https = require("https")
78const app = require ( "../index.js" )
89
910// make an http request on the specified path
10- function makeRequest ( path = "/" , secure = true , port = PORT ) {
11+ function makeRequest ( path = "/" , secure = true , port = HTTPS_PORT ) {
1112 const options = {
1213 host : "localhost" ,
1314 port : port ,
@@ -35,23 +36,23 @@ function makeRequest(path = "/", secure = true, port = PORT) {
3536describe ( "Testing https-localhost" , ( ) => {
3637 it ( "works as a module" , async function ( ) {
3738 app . get ( "/test/module" , ( req , res ) => res . send ( "TEST" ) )
38- await app . listen ( PORT )
39+ await app . listen ( HTTPS_PORT )
3940 await makeRequest ( "/test/module" )
4041 . then ( res => assert ( res . data === "TEST" ) )
4142 await app . server . close ( )
4243 } )
4344
4445 it ( "works as a module serving static files" , async function ( ) {
45- app . serve ( "test" , PORT )
46+ app . serve ( "test" , HTTPS_PORT )
4647 await makeRequest ( "/static.html" )
4748 . then ( res => assert (
4849 res . data . toString ( ) === fs . readFileSync ( "test/static.html" ) . toString ( ) ) )
4950 await app . server . close ( )
5051 } )
5152
5253 it ( "redirect http to https" , async function ( ) {
53- await app . redirect ( )
54- await makeRequest ( "/" , false , 80 )
54+ await app . redirect ( HTTP_PORT )
55+ await makeRequest ( "/" , false , HTTP_PORT )
5556 . then ( res => assert ( res . statusCode === 301 ) )
5657 } )
5758} )
0 commit comments