Files
healer-man/src/app/randomizedBiteSizedContent.test.ts
T
2026-09-20 18:08:43 -04:00

47 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import {
ensureRandomizedBiteSizedRunContent,
randomizedBiteSizedModelUrls,
} from "./randomizedBiteSizedContent";
describe("randomized bite-sized run content", () => {
it("derives only the distinct model URLs selected by the shared run seed", () => {
const first = randomizedBiteSizedModelUrls("asset-seed");
const second = randomizedBiteSizedModelUrls("asset-seed");
expect(first).toEqual(second);
expect(first.length).toBeGreaterThan(1);
expect(new Set(first).size).toBe(first.length);
expect(first.every((url) => url.startsWith("/assets/") && url.endsWith(".glb"))).toBe(true);
});
it("installs the base location and only the rolled creature model packs before entry", async () => {
const installPack = vi.fn(async () => undefined);
const installUrls = vi.fn(async () => undefined);
await ensureRandomizedBiteSizedRunContent("download-seed", {
development: false,
installPack,
installUrls,
packIsUsable: () => false,
packHasUpdate: () => false,
});
expect(installPack).toHaveBeenCalledWith("activity:randomized-bite-sized");
expect(installUrls).toHaveBeenCalledWith(randomizedBiteSizedModelUrls("download-seed"));
expect(installPack.mock.invocationCallOrder[0]).toBeLessThan(installUrls.mock.invocationCallOrder[0]);
});
it("skips network installation in the unrestricted development asset server", async () => {
const installPack = vi.fn(async () => undefined);
const installUrls = vi.fn(async () => undefined);
await ensureRandomizedBiteSizedRunContent("dev-seed", {
development: true,
installPack,
installUrls,
packIsUsable: () => false,
packHasUpdate: () => false,
});
expect(installPack).not.toHaveBeenCalled();
expect(installUrls).not.toHaveBeenCalled();
});
});