// Shared fixture for the map-view suites. Declares the `build` helper only -- // no `test_*` methods -- so each split suite inherits it without the runner // re-running every test in every subclass. import { TestCase } from "./test_case.js"; import { setupDom } from "./dom.js"; import { MapView } from "../../client/js/map_view.js"; import { CIVILISATIONS, PROTO_UNITS } from "../../shared/data.js"; import { mapLayers } from "./helpers.js"; export class MapViewFixture extends TestCase { async build(state) { const env = await setupDom(); const map = new MapView(env.$("#map-viewport"), env.$("#map-world"), mapLayers(env.$)); map.$viewport.width = () => 800; map.$viewport.height = () => 600; const snapshot = state.snapshot(0); // The snapshot ships the nations in their seeded order; rebuild the full // catalogue in that same order so owner indices line up, exactly as the // game screen does. const catalogue = snapshot.civs.map( (c) => CIVILISATIONS.find((full) => full.id === c.id) || c ); map.setCatalogue(catalogue, PROTO_UNITS); map.applySnapshot(snapshot); return { env, map, snapshot }; } }