Single module modding
This commit is contained in:
+4
-4
@@ -22,7 +22,7 @@ async function load(script: string) {
|
||||
id: "testmod",
|
||||
name: "Test",
|
||||
version: "1.0.0",
|
||||
scripts: { client: "scripts/client.ts" },
|
||||
main: "scripts/client.ts",
|
||||
}),
|
||||
);
|
||||
Deno.writeTextFileSync(`${dir}/testmod/scripts/client.ts`, script);
|
||||
@@ -39,7 +39,7 @@ async function load(script: string) {
|
||||
Deno.test("hud layers draw in order on the same space, and one that throws is removed", async () => {
|
||||
await load(`
|
||||
import type { ClientContext } from "cubi/client";
|
||||
export function setup(ctx: ClientContext) {
|
||||
export function client(ctx: ClientContext) {
|
||||
ctx.hud.register("testmod:bar", { on_render(_g, hud) { hud.left_height += 10; } });
|
||||
ctx.hud.register("testmod:broken", { on_render() { throw new Error("broken"); } });
|
||||
const above = {
|
||||
@@ -75,13 +75,13 @@ Deno.test("hud layers draw in order on the same space, and one that throws is re
|
||||
Deno.test("hud layers are in the mod's namespace, one to an id", async () => {
|
||||
const layer = `{ on_render() {} }`;
|
||||
await assertRejects(
|
||||
() => load(`export function setup(ctx) { ctx.hud.register("bworld:hotbar", ${layer}); }`),
|
||||
() => load(`export function client(ctx) { ctx.hud.register("bworld:hotbar", ${layer}); }`),
|
||||
Error,
|
||||
`must be in the namespace "testmod"`,
|
||||
);
|
||||
await assertRejects(
|
||||
() =>
|
||||
load(`export function setup(ctx) {
|
||||
load(`export function client(ctx) {
|
||||
ctx.hud.register("testmod:bar", ${layer});
|
||||
ctx.hud.register("testmod:bar", ${layer});
|
||||
}`),
|
||||
|
||||
Reference in New Issue
Block a user