Export app as a separate entry from master.js

Change the module exports from master.js to allow additional objects to
be passed to allow better unit testing.
This commit is contained in:
Hornwitser committed 2019-09-04 17:36:06 +02:00
1 parent af2471b427
commit 5d6f6de379
2 files changed
+6 -4

No files matched your search

+3 -1
View File
@@ -971,7 +971,9 @@ async function startServer() {
}
}
module.exports = app;
module.exports = {
app,
}
if (module === require.main) {
console.warn(`
+3 -3
View File
@@ -4,7 +4,7 @@ const validateHTML = require('html5-validator');
const parallel = require('mocha.parallel');
const jwt = require("jsonwebtoken");
const app = require('./master.js');
const master = require('./master.js');
const config = require('./config.json');
const authenticate = require('lib/authenticate');
@@ -15,7 +15,7 @@ const token =
jwt.sign( { id: "api" }, config.masterAuthSecret, { expiresIn: 600 });
async function get(path) {
return await request(app).get(path).expect(200);
return await request(master.app).get(path).expect(200);
}
async function getValidate(path) {
@@ -46,7 +46,7 @@ describe('Master server endpoint testing', function() {
it(`sends some HTML when accessing ${path}`, () => getValidate(path));
}
});
let persistentMaster = request(app);
let persistentMaster = request(master.app);
describe("#POST /api/place", function() {
it("adds an itemStack to the masters inventory", function() {
return persistentMaster.post("/api/place").send({