mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Cover non-class exports and installation errors in PluginLoader tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1ea4d470b
commit
68c5ea82e7
1 file changed
+15
@@ -31,6 +31,9 @@ describe("lib/PluginLoader", function() {
|
||||
}`,
|
||||
"empty.js": "",
|
||||
"wrong_parent.js": "export class ControllerPlugin {};\n",
|
||||
"not_class.js": "export const ControllerPlugin = 1;\n",
|
||||
"installation_error.js": `import { InstallationError } from "@clusterio/lib";
|
||||
export default function() { throw new InstallationError("missing dependency"); }`,
|
||||
"throwing.js": `export default async function({ plugin }) {
|
||||
await new Promise(resolve => setTimeout(resolve, plugin.delay ?? 0));
|
||||
throw new Error(\`\${plugin.name} failed\`);
|
||||
@@ -129,6 +132,18 @@ describe("lib/PluginLoader", function() {
|
||||
{ message: "PluginError: Expected ControllerPlugin exported from test to extend BaseControllerPlugin" },
|
||||
);
|
||||
});
|
||||
it("should throw if the class export is not a class", async function() {
|
||||
await assert.rejects(
|
||||
loadOne(info("test", "not_class.js")),
|
||||
{ message: "PluginError: Expected plugin test to export a class named ControllerPlugin" },
|
||||
);
|
||||
});
|
||||
it("should not wrap installation errors", async function() {
|
||||
await assert.rejects(
|
||||
loadOne(info("test", "installation_error.js")),
|
||||
err => err instanceof lib.InstallationError,
|
||||
);
|
||||
});
|
||||
it("should finish loading the rest before throwing the first error in list order", async function() {
|
||||
const ok = info("ok", "function.js");
|
||||
await assert.rejects(
|
||||
|
||||
Reference in new issue
Block a user