mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 23:24:52 +09:00
Fix misc problems detected by ESLint
Reformat and clean up issues detected by ESLint.
This commit is contained in:
1 parent
8cb21c5fa8
commit
e9f5cae4f0
34 files changed
+132
-189
No files matched your search
@@ -156,7 +156,7 @@ describe("Integration of Clusterio", function() {
|
||||
],
|
||||
];
|
||||
|
||||
for (let [prop, value, , ] of testConfigs) {
|
||||
for (let [prop, value, ,] of testConfigs) {
|
||||
value = `"'${JSON.stringify(value).replace(/"/g, process.platform === "win32" ? '""' : '\\"')}'"`;
|
||||
let args = `--instance test --field factorio.settings --prop ${prop} --value ${value}`;
|
||||
await exec(`node clusterctl --config ${controlConfigPath} set-instance-config-prop ${args}`);
|
||||
|
||||
@@ -23,6 +23,7 @@ class TestControl extends link.Link {
|
||||
}
|
||||
|
||||
async debugWsMessageEventHandler() { }
|
||||
|
||||
async instanceOutputEventHandler() { }
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ class TestControlConnector extends link.WebSocketClientConnector {
|
||||
// Mark that this test takes a lot of time, or depeneds on a test
|
||||
// that takes a lot of time.
|
||||
function slowTest(test) {
|
||||
// eslint-disable-next-line no-process-env
|
||||
if (process.env.FAST_TEST) {
|
||||
test.skip();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("Integration of lib/factorio/server", function() {
|
||||
|
||||
before(async function() {
|
||||
// Delete result from previous run of these tests
|
||||
if (fs.existsSync(writePath)) {
|
||||
if (await fs.pathExists(writePath)) {
|
||||
await fs.remove(writePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ describe("lib/config/classes", function() {
|
||||
});
|
||||
|
||||
it("should work if field is in enum", function() {
|
||||
testInstance.set("enum", "c"),
|
||||
testInstance.set("enum", "c");
|
||||
assert.equal(testInstance.get("enum"), "c");
|
||||
});
|
||||
|
||||
@@ -299,7 +299,7 @@ describe("lib/config/classes", function() {
|
||||
});
|
||||
|
||||
it("should work if field is optional", function() {
|
||||
testInstance.set("test", "spam"),
|
||||
testInstance.set("test", "spam");
|
||||
assert.equal(testInstance.get("test"), "spam");
|
||||
});
|
||||
|
||||
@@ -311,7 +311,7 @@ describe("lib/config/classes", function() {
|
||||
});
|
||||
|
||||
it("should treat empty string as null", function() {
|
||||
testInstance.set("test", ""),
|
||||
testInstance.set("test", "");
|
||||
assert.equal(testInstance.get("test"), null);
|
||||
});
|
||||
|
||||
@@ -451,7 +451,8 @@ describe("lib/config/classes", function() {
|
||||
});
|
||||
it("should construct a finalized class", function() {
|
||||
TestConfig.finalize();
|
||||
new TestConfig();
|
||||
let config = new TestConfig();
|
||||
assert(config);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ describe("lib/database", function() {
|
||||
new Error("Expected all keys to be string but got number")
|
||||
);
|
||||
assert.throws(
|
||||
() => database.mapToObject(new Map([[Symbol(), 1]])),
|
||||
() => database.mapToObject(new Map([[Symbol("test"), 1]])),
|
||||
new Error("Expected all keys to be string but got symbol")
|
||||
);
|
||||
});
|
||||
|
||||
@@ -18,5 +18,5 @@ describe("lib/factorio/export", function() {
|
||||
let locale = await factorio._exportLocale(testServer, new Map(), ["base"], "en");
|
||||
assert.deepEqual(locale, new Map([["test.key-a", "1"], ["test.key-b", "2"]]));
|
||||
});
|
||||
});;
|
||||
});
|
||||
});
|
||||
@@ -93,7 +93,7 @@ describe("lib/factorio/server", function() {
|
||||
|
||||
it("should return a port number in the dynamic range", function() {
|
||||
function validate(port) {
|
||||
return 49152 <= port && port <= 65535;
|
||||
return (49152 <= port && port <= 65535);
|
||||
}
|
||||
for (let i=0; i < 20; i++) {
|
||||
assert(validate(factorio._randomDynamicPort()));
|
||||
|
||||
@@ -5,7 +5,7 @@ const path = require("path");
|
||||
|
||||
const generateSSLcert = require("lib/generateSSLcert");
|
||||
|
||||
describe("generateSSLcert.js(options)", ()=>{
|
||||
describe("generateSSLcert.js(options)", function() {
|
||||
let testDir = path.join("temp", "test", "certTest");
|
||||
before(async function() {
|
||||
await fs.remove(testDir);
|
||||
@@ -13,6 +13,7 @@ describe("generateSSLcert.js(options)", ()=>{
|
||||
|
||||
it("Creates a folder with a .crt and .key file in it", async function() {
|
||||
this.timeout(1000);
|
||||
// eslint-disable-next-line no-process-env
|
||||
if (process.env.FAST_TEST) {
|
||||
this.skip();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ describe("lib/link/connectors", function() {
|
||||
describe(".processHandshake()", function() {
|
||||
it("should close on invalid message", function() {
|
||||
testConnector._socket.closeCalled = false;
|
||||
testConnector._processHandshake({ data: "invalid message" }),
|
||||
testConnector._processHandshake({ data: "invalid message" });
|
||||
assert(testConnector._socket.closeCalled, "Close was not called on the socket");
|
||||
});
|
||||
it("should call register on hello", function() {
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("lib/link/link", function() {
|
||||
);
|
||||
});
|
||||
it("should set the handler", function() {
|
||||
let handler = (message) => {};
|
||||
function handler(message) { }
|
||||
testLink.setHandler("handler_test", handler, (message) => true);
|
||||
assert.equal(testLink._handlers.get("handler_test"), handler);
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("lib/link/messages", function() {
|
||||
|
||||
let handlerResult;
|
||||
it("should attach handler to a target link", function() {
|
||||
testRequest.attach(testTargetLink, async (message) => handlerResult );
|
||||
testRequest.attach(testTargetLink, async (message) => handlerResult);
|
||||
assert(testTargetLink._handlers.has("test_request"), "Handler was not set");
|
||||
});
|
||||
it("should send result of calling the handler", async function() {
|
||||
@@ -83,9 +83,7 @@ describe("lib/link/messages", function() {
|
||||
testSourceLink.connector.send = (type, data) => {
|
||||
request = { type, data };
|
||||
};
|
||||
testSourceLink.waitFor = (type, condition) => {
|
||||
return { data: { type, request }};
|
||||
};
|
||||
testSourceLink.waitFor = (type, condition) => ({ data: { type, request }});
|
||||
assert.deepEqual(
|
||||
await testRequest.send(testSourceLink, { test: "request" }),
|
||||
{ type: "test_response", request: { type: "test_request", data: { test: "request" }}}
|
||||
@@ -94,9 +92,7 @@ describe("lib/link/messages", function() {
|
||||
delete testSourceLink.waitFor;
|
||||
});
|
||||
it("should throw error response", async function() {
|
||||
testSourceLink.waitFor = (type, condition) => {
|
||||
return { data: { error: "test error" }};
|
||||
};
|
||||
testSourceLink.waitFor = (type, condition) => ({ data: { error: "test error" }});
|
||||
await assert.rejects(
|
||||
testRequest.send(testSourceLink, { test: "blah" }),
|
||||
new errors.RequestError("test error")
|
||||
|
||||
+3
-22
@@ -3,31 +3,12 @@ var assert = require("assert");
|
||||
var objectOps = require("lib/objectOps");
|
||||
|
||||
describe("objectOps.js", function(){
|
||||
/*describe("objectOps.clone()", function(){
|
||||
it("clones javascript objects", function(){
|
||||
var object1 = {hello:"world", cat:{legs:4, name:"Kitty", colors:["brown", "yellow", "purple"]}};
|
||||
var object2 = {};
|
||||
object2 = objectOps.clone(object1);
|
||||
|
||||
assert.equal(object2.cat.name, object1.cat.name)
|
||||
assert.equal(object1.hello, object2.hello)
|
||||
});
|
||||
it("does not deep clone objects", function(){
|
||||
var obj1 = {hello:"world", cat:{legs:4, name:"Kitty", colors:["brown", "yellow", "purple"]}};
|
||||
var obj2 = {};
|
||||
obj2 = objectOps.clone(obj1);
|
||||
|
||||
obj1.cat.colors = "black";
|
||||
assert.equal(obj1.cat.colors, "black");
|
||||
assert.notEqual(obj2.cat.colors[1], "yellow");
|
||||
});
|
||||
});*/
|
||||
describe("objectOps.deepclone()", function(){
|
||||
it("deep clones javascript objects", function(){
|
||||
var obj1 = { hello:"world", cat:{ legs:4, name:"Kitty", colors:["brown", "yellow", "purple"] }};
|
||||
var obj1 = { hello: "world", cat: { legs: 4, name: "Kitty", colors: ["brown", "yellow", "purple"] }};
|
||||
var obj2 = {};
|
||||
obj2 = objectOps.deepclone(obj1);
|
||||
|
||||
|
||||
obj1.cat.colors = "black";
|
||||
assert.equal(obj1.cat.colors, "black");
|
||||
assert.equal(obj2.cat.colors[1], "yellow");
|
||||
@@ -38,4 +19,4 @@ describe("objectOps.js", function(){
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -103,7 +103,7 @@ describe("lib/plugin", function() {
|
||||
plugin.attachPluginMessages(mockLink, {}, null);
|
||||
});
|
||||
it("should attach handler for the given message", function() {
|
||||
let mockEventEventHandler = function() {};
|
||||
function mockEventEventHandler() { };
|
||||
plugin.attachPluginMessages(mockLink, { name: "test", messages: { mockEvent }}, { mockEventEventHandler });
|
||||
assert(mockLink._handlers.get("test:test_event"), "handler was not registered");
|
||||
});
|
||||
|
||||
@@ -523,7 +523,7 @@ describe("lib/prometheus", function() {
|
||||
|
||||
let serializedResult = {
|
||||
metric: { type: "type", name: "name", help: "Help", labels: ["a", "b"] },
|
||||
samples: [ ['a="1",b="2"', 1], ['a="3",b="4"', 5] ],
|
||||
samples: [['a="1",b="2"', 1], ['a="3",b="4"', 5]],
|
||||
};
|
||||
let deserializedResult = {
|
||||
metric: new prometheus.Metric("type", "name", "Help", ["a", "b"]),
|
||||
|
||||
Reference in new issue
Block a user