mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Fix usage of assert.rejects
This commit is contained in:
8 files changed
+47
-47
No files matched your search
@@ -201,13 +201,13 @@ 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");
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error(
|
||||
`${filepath}: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data`
|
||||
)
|
||||
);
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", `${filepath}.notExist`),
|
||||
);
|
||||
});
|
||||
@@ -218,12 +218,12 @@ describe("lib/config/classes", function() {
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await fs.writeFile(filepath, "undefined");
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await fs.writeFile(filepath, "[]");
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
|
||||
+5
-5
@@ -22,9 +22,9 @@ describe("rce_ops", function() {
|
||||
await lib.handlePluginUpdate("foo", [{ npmPackage: "foo" }]);
|
||||
});
|
||||
it("rejects when plugin not installed", async function() {
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
lib.handlePluginUpdate("foo", []),
|
||||
"Plugin foo is not installed on this machine"
|
||||
/Plugin foo is not installed on this machine/
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -50,14 +50,14 @@ describe("rce_ops", function() {
|
||||
});
|
||||
it("rejects when name too long", async function() {
|
||||
const pluginName = "a".repeat(215);
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
);
|
||||
});
|
||||
it("rejects when invalid symbol present", async function() {
|
||||
const pluginName = "?";
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
);
|
||||
@@ -69,7 +69,7 @@ describe("rce_ops", function() {
|
||||
return { ok: false };
|
||||
};
|
||||
|
||||
assert.rejects(lib.handlePluginInstall("foo"), "Unknown plugin: foo");
|
||||
await assert.rejects(lib.handlePluginInstall("foo"), /Unknown plugin: foo/);
|
||||
assert.equal(calledWith, "https://registry.npmjs.com/foo");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -240,18 +240,18 @@ describe("lib/subscriptions", function() {
|
||||
subscriptions.handle(RegisteredEvent);
|
||||
});
|
||||
|
||||
it("should not accept subscriptions to unregistered events", function() {
|
||||
it("should not accept subscriptions to unregistered events", async function() {
|
||||
const request = new lib.SubscriptionRequest(RegisteredEvent.name, true);
|
||||
request.eventName = UnregisteredEvent.name;
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Unregistered Event class ${UnregisteredEvent.name}`)
|
||||
);
|
||||
});
|
||||
it("should not accept subscriptions to events not handled by the class", function() {
|
||||
it("should not accept subscriptions to events not handled by the class", async function() {
|
||||
const request = new lib.SubscriptionRequest(RegisteredEvent.name, true);
|
||||
request.eventName = StringPermissionEvent.name;
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Event ${StringPermissionEvent.eventName} is not a registered as subscribable`)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user