@@ -34,7 +34,28 @@ function makeRequest(path = "/", secure = true, port = HTTPS_PORT) {
3434 } )
3535}
3636
37- // TESTS
37+ // TESTS INSTALL
38+ describe ( "Testing the installation script" , function ( ) {
39+ // timeout 5 min
40+ this . timeout ( 300000 )
41+
42+ // remove a file, this will force the reinstallation
43+ fs . unlinkSync ( "cert/localhost.crt" )
44+
45+ it ( "installs correctly" , async function ( ) {
46+ await require ( "../cert/generate.js" ) ( )
47+ assert ( fs . existsSync ( "cert/localhost.crt" ) )
48+ assert ( fs . existsSync ( "cert/localhost.key" ) )
49+ } )
50+
51+ it ( "skips installation if files exists" , async function ( ) {
52+ await require ( "../cert/generate.js" ) ( )
53+ assert ( fs . existsSync ( "cert/localhost.crt" ) )
54+ assert ( fs . existsSync ( "cert/localhost.key" ) )
55+ } )
56+ } )
57+
58+ // TESTS MODULE
3859describe ( "Testing https-localhost" , ( ) => {
3960 // close the server after each test
4061 afterEach ( ( ) => app . server . close ( ) )
@@ -120,15 +141,3 @@ describe("Testing https-localhost", () => {
120141 . then ( res => assert ( res . headers [ "content-encoding" ] === "gzip" ) )
121142 } )
122143} )
123-
124- // TESTS
125- describe ( "Testing the installation script" , function ( ) {
126- // timeout 5 min
127- this . timeout ( 300000 )
128-
129- it ( "installs correctly" , async function ( ) {
130- await require ( "../cert/generate.js" ) ( )
131- assert ( fs . existsSync ( "cert/localhost.crt" ) )
132- assert ( fs . existsSync ( "cert/localhost.key" ) )
133- } )
134- } )
0 commit comments