mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Fix expected error messages for assert rejects
This commit is contained in:
4 files changed
+13
-29
No files matched your search
@@ -201,32 +201,16 @@ describe("lib/config/classes", function() {
|
||||
const filepath = path.join("temp", "test", "config_test.json");
|
||||
it("should throw for file and json errors", async function() {
|
||||
await fs.writeFile(filepath, "abc");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error(
|
||||
`${filepath}: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data`
|
||||
)
|
||||
);
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", `${filepath}.notExist`),
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await assert.rejects(TestConfig.fromFile("local", `${filepath}.notExist`));
|
||||
});
|
||||
it("should throw on incorrect input passed", async function() {
|
||||
await fs.writeFile(filepath, "null");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await fs.writeFile(filepath, "undefined");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await fs.writeFile(filepath, "[]");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
});
|
||||
it("should load defaults for missing fields", async function() {
|
||||
await fs.writeJSON(filepath, {
|
||||
|
||||
+2
-2
@@ -52,14 +52,14 @@ describe("rce_ops", function() {
|
||||
const pluginName = "a".repeat(215);
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
{ message: `Invalid plugin name: ${pluginName}` }
|
||||
);
|
||||
});
|
||||
it("rejects when invalid symbol present", async function() {
|
||||
const pluginName = "?";
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
{ message: `Invalid plugin name: ${pluginName}` },
|
||||
);
|
||||
});
|
||||
it("rejects unregistered packages", async function() {
|
||||
|
||||
@@ -245,7 +245,7 @@ describe("lib/subscriptions", function() {
|
||||
request.eventName = UnregisteredEvent.name;
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Unregistered Event class ${UnregisteredEvent.name}`)
|
||||
new Error(`Event ${UnregisteredEvent.name} is not a registered event`)
|
||||
);
|
||||
});
|
||||
it("should not accept subscriptions to events not handled by the class", async function() {
|
||||
@@ -253,7 +253,7 @@ describe("lib/subscriptions", function() {
|
||||
request.eventName = StringPermissionEvent.name;
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Event ${StringPermissionEvent.eventName} is not a registered as subscribable`)
|
||||
new Error(`Event ${StringPermissionEvent.name} is not a registered as subscribable`)
|
||||
);
|
||||
});
|
||||
it("should accept a subscription", async function() {
|
||||
|
||||
Reference in new issue
Block a user