Every recipe type registered from shared scripts
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// create's recipe types: read and checked when the server starts, and shown by the recipe viewer
|
||||
// create's recipe types: read and checked when the mod loads, and shown by the recipe viewer
|
||||
import { assert, assertEquals, assertThrows } from "@std/assert";
|
||||
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import { tag_api } from "$/common/tags.ts";
|
||||
import type { ClientContext } from "$/common/mod_api/client.ts";
|
||||
import type { RecipeReader } from "$/common/mod_api/shared.ts";
|
||||
import { recipe_lookup } from "$/common/mod_loader.ts";
|
||||
import {
|
||||
COMPACTING,
|
||||
parse_processing,
|
||||
PRESSING,
|
||||
processing_recipes,
|
||||
processing_type,
|
||||
type ProcessingRecipe,
|
||||
} from "$/mods/create/scripts/recipes/processing.ts";
|
||||
import { inputs, outputs } from "$/mods/recipe_viewer/scripts/recipes.ts";
|
||||
import { RecipeIndex } from "$/mods/recipe_viewer/scripts/recipes_screen.ts";
|
||||
@@ -24,7 +27,7 @@ const lookup = () => ({
|
||||
|
||||
Deno.test("create's pressing recipes are read with every item each ingredient stands for", async () => {
|
||||
const { game } = await test_game("mods");
|
||||
const recipes = processing_recipes(game.recipes.by_type.get(PRESSING.id) ?? [], PRESSING, lookup());
|
||||
const recipes = recipe_lookup(() => game.recipes).all<ProcessingRecipe>(PRESSING.id);
|
||||
const sheet = recipes.find((recipe) => recipe.results[0].id === "create:iron_sheet");
|
||||
assert(sheet, "iron is pressed into sheets");
|
||||
assert(sheet.ingredients[0].includes("bworld:iron_ingot"));
|
||||
@@ -50,9 +53,10 @@ Deno.test("a pressing recipe that a press couldn't make says what's wrong with i
|
||||
assertEquals(problems({ ingredients: ["bworld:iron_ingot"], results: [sheet], processing_time: 100 }).length, 1);
|
||||
assertEquals(problems({ results: [sheet] }).length, 1);
|
||||
|
||||
// the server doesn't start with one, and says which
|
||||
// the mod doesn't load with one, and says what's wrong
|
||||
const type = processing_type(PRESSING, lookup());
|
||||
assertThrows(
|
||||
() => processing_recipes([{ ingredients: ["bworld:no_such_ingot"], results: [sheet] }], PRESSING, lookup()),
|
||||
() => type.parse({ ingredients: ["bworld:no_such_ingot"], results: [sheet] }, {} as RecipeReader),
|
||||
Error,
|
||||
"bworld:no_such_ingot",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user