Initial Commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { SAND_VM_BRIDGE_CODES, SandboxVmBridgeError } from "./error-codes.js";
|
||||
|
||||
describe("SAND_VM_BRIDGE_CODES", () => {
|
||||
it("registers five namespaced codes", { timeout: 5000 }, () => {
|
||||
expect(SAND_VM_BRIDGE_CODES.INVALID_PLUGIN_SURFACE).toBe(
|
||||
"SAND_VM_BRIDGE.INVALID_PLUGIN_SURFACE"
|
||||
);
|
||||
expect(SAND_VM_BRIDGE_CODES.MARSHAL_FAILED).toBe(
|
||||
"SAND_VM_BRIDGE.MARSHAL_FAILED"
|
||||
);
|
||||
expect(SAND_VM_BRIDGE_CODES.UNMARSHAL_FAILED).toBe(
|
||||
"SAND_VM_BRIDGE.UNMARSHAL_FAILED"
|
||||
);
|
||||
expect(SAND_VM_BRIDGE_CODES.HANDLER_REJECTED).toBe(
|
||||
"SAND_VM_BRIDGE.HANDLER_REJECTED"
|
||||
);
|
||||
expect(SAND_VM_BRIDGE_CODES.LIFECYCLE_FAILED).toBe(
|
||||
"SAND_VM_BRIDGE.LIFECYCLE_FAILED"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("SandboxVmBridgeError", () => {
|
||||
it("carries code, message, name + cause", { timeout: 5000 }, () => {
|
||||
const cause = new Error("boom");
|
||||
const err = new SandboxVmBridgeError(
|
||||
SAND_VM_BRIDGE_CODES.HANDLER_REJECTED,
|
||||
"sandboxed handler threw",
|
||||
{ cause }
|
||||
);
|
||||
expect(err.code).toBe("SAND_VM_BRIDGE.HANDLER_REJECTED");
|
||||
expect(err.message).toBe("sandboxed handler threw");
|
||||
expect(err.name).toBe("SandboxVmBridgeError");
|
||||
expect(err.cause).toBe(cause);
|
||||
});
|
||||
|
||||
it("works without options", { timeout: 5000 }, () => {
|
||||
const err = new SandboxVmBridgeError(
|
||||
SAND_VM_BRIDGE_CODES.LIFECYCLE_FAILED,
|
||||
"boot failed"
|
||||
);
|
||||
expect(err.code).toBe("SAND_VM_BRIDGE.LIFECYCLE_FAILED");
|
||||
expect(err.cause).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user