mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 14:20:45 +00:00
31 lines
969 B
TypeScript
31 lines
969 B
TypeScript
import { describe, expect, test, vi } from "vitest";
|
|
import { FetchGameMapLoader } from "../../../src/core/game/FetchGameMapLoader";
|
|
import { GameMapType } from "../../../src/core/game/Game";
|
|
|
|
describe("FetchGameMapLoader", () => {
|
|
test("resolves each map file through the provided path resolver", async () => {
|
|
const fetchMock = vi.fn(async (url: string) => ({
|
|
ok: true,
|
|
arrayBuffer: async () => new ArrayBuffer(0),
|
|
json: async () => ({ url }),
|
|
statusText: "OK",
|
|
}));
|
|
vi.stubGlobal("fetch", fetchMock);
|
|
|
|
const loader = new FetchGameMapLoader(
|
|
(path) => `/_assets/maps/${path}.hashed`,
|
|
);
|
|
const mapData = loader.getMapData(GameMapType.BritanniaClassic);
|
|
|
|
expect(mapData.webpPath).toBe(
|
|
"/_assets/maps/britanniaclassic/thumbnail.webp.hashed",
|
|
);
|
|
|
|
await mapData.manifest();
|
|
|
|
expect(fetchMock).toHaveBeenCalledWith(
|
|
"/_assets/maps/britanniaclassic/manifest.json.hashed",
|
|
);
|
|
});
|
|
});
|