fix(tests): Got bin/server.js unit test coverage to 100%

This commit is contained in:
Chris Troutner
2022-06-19 20:21:40 -07:00
parent d8addd5b27
commit 62a7fcb16d
2 changed files with 33 additions and 8 deletions
+8 -7
View File
@@ -33,6 +33,7 @@ class Server {
this.controllers = new Controllers()
this.mongoose = mongoose
this.config = config
this.process = process
}
async startServer () {
@@ -88,7 +89,7 @@ class Server {
console.log(`Running server in environment: ${this.config.env}`)
wlogger.info(`Running server in environment: ${this.config.env}`)
await app.listen(this.config.port)
this.server = await app.listen(this.config.port)
console.log(`Server started on ${this.config.port}`)
// Create the system admin user.
@@ -114,14 +115,14 @@ class Server {
console.log(
'Exiting after 5 seconds. Depending on process manager to restart.'
)
await sleep(5000)
process.exit(1)
await this.sleep(5000)
this.process.exit(1)
}
}
sleep (ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
}
function sleep (ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
module.exports = Server