Skip to content

Commit 607742d

Browse files
committed
Test install
1 parent baca26a commit 607742d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

cert/generate.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const MKCERT_VERSION = "v1.3.0"
88

99
// get the executable name
1010
function getExe() {
11+
/* istanbul ignore next: tested on all platform on travis */
1112
switch (process.platform) {
1213
case "darwin":
1314
return "mkcert-" + MKCERT_VERSION + "-darwin-amd64"
@@ -45,8 +46,9 @@ function mkcert(path, exe) {
4546
"-key-file " + path + "localhost.key localhost", (err, stdout, stderr) => {
4647
console.log(stdout)
4748
console.error(stderr)
49+
/* istanbul ignore if: cannot be tested */
4850
if (err) reject(err)
49-
else resolve()
51+
resolve()
5052
})
5153
})
5254
}
@@ -66,6 +68,7 @@ async function main() {
6668
}
6769

6870
// run as script
71+
/* istanbul ignore if: cannot be tested */
6972
if (require.main === module)
7073
try { main() } catch (err) { console.error("\nExec error: " + err) }
7174

test/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const http = require("http")
44
const https = require("https")
55

66
const app = require("../index.js")
7+
const install = require("../cert/generate.js")
78

89
const HTTPS_PORT = 4443
910
const HTTP_PORT = 8080
@@ -120,3 +121,15 @@ describe("Testing https-localhost", () => {
120121
.then(res => assert(res.headers["content-encoding"] === "gzip"))
121122
})
122123
})
124+
125+
// TESTS
126+
describe("Testing the installation script", function() {
127+
// timeout 5 min
128+
this.timeout(300000)
129+
130+
it("installs correctly", async function() {
131+
await install()
132+
assert(fs.existsSync("cert/localhost.crt"))
133+
assert(fs.existsSync("cert/localhost.key"))
134+
})
135+
})

0 commit comments

Comments
 (0)