mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
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:
1 parent
af2471b427
commit
5d6f6de379
2 files changed
+6
-4
No files matched your search
@@ -971,7 +971,9 @@ async function startServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = {
|
||||||
|
app,
|
||||||
|
}
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
console.warn(`
|
console.warn(`
|
||||||
|
|||||||
+3
-3
@@ -4,7 +4,7 @@ const validateHTML = require('html5-validator');
|
|||||||
const parallel = require('mocha.parallel');
|
const parallel = require('mocha.parallel');
|
||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
|
|
||||||
const app = require('./master.js');
|
const master = require('./master.js');
|
||||||
const config = require('./config.json');
|
const config = require('./config.json');
|
||||||
const authenticate = require('lib/authenticate');
|
const authenticate = require('lib/authenticate');
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const token =
|
|||||||
jwt.sign( { id: "api" }, config.masterAuthSecret, { expiresIn: 600 });
|
jwt.sign( { id: "api" }, config.masterAuthSecret, { expiresIn: 600 });
|
||||||
|
|
||||||
async function get(path) {
|
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) {
|
async function getValidate(path) {
|
||||||
@@ -46,7 +46,7 @@ describe('Master server endpoint testing', function() {
|
|||||||
it(`sends some HTML when accessing ${path}`, () => getValidate(path));
|
it(`sends some HTML when accessing ${path}`, () => getValidate(path));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let persistentMaster = request(app);
|
let persistentMaster = request(master.app);
|
||||||
describe("#POST /api/place", function() {
|
describe("#POST /api/place", function() {
|
||||||
it("adds an itemStack to the masters inventory", function() {
|
it("adds an itemStack to the masters inventory", function() {
|
||||||
return persistentMaster.post("/api/place").send({
|
return persistentMaster.post("/api/place").send({
|
||||||
|
|||||||
Reference in new issue
Block a user