ui/phase-13: planet inspector — read-only
Plumbs the map → inspector pathway: a click on a planet selects it through the new SelectionStore, the sidebar Inspector tab swaps its empty-state copy for a per-kind read-only field set, and a mobile-only bottom-sheet mirrors the same content over the map. Field projection in api/game-state.ts now surfaces every documented planet field.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// SelectionStore unit tests. The store is in-memory only and carries
|
||||
// no async lifecycle, so the cases focus on the rune transitions and
|
||||
// the post-`dispose` no-op contract.
|
||||
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { SelectionStore } from "../src/lib/selection.svelte";
|
||||
|
||||
describe("SelectionStore", () => {
|
||||
test("initial state has no selection", () => {
|
||||
const store = new SelectionStore();
|
||||
expect(store.selected).toBeNull();
|
||||
});
|
||||
|
||||
test("selectPlanet records the planet id", () => {
|
||||
const store = new SelectionStore();
|
||||
store.selectPlanet(42);
|
||||
expect(store.selected).toEqual({ kind: "planet", id: 42 });
|
||||
});
|
||||
|
||||
test("selectPlanet replaces the previous selection", () => {
|
||||
const store = new SelectionStore();
|
||||
store.selectPlanet(1);
|
||||
store.selectPlanet(2);
|
||||
expect(store.selected).toEqual({ kind: "planet", id: 2 });
|
||||
});
|
||||
|
||||
test("clear resets the selection to null", () => {
|
||||
const store = new SelectionStore();
|
||||
store.selectPlanet(7);
|
||||
store.clear();
|
||||
expect(store.selected).toBeNull();
|
||||
});
|
||||
|
||||
test("dispose blocks subsequent mutations", () => {
|
||||
const store = new SelectionStore();
|
||||
store.selectPlanet(3);
|
||||
store.dispose();
|
||||
expect(store.selected).toBeNull();
|
||||
|
||||
store.selectPlanet(4);
|
||||
expect(store.selected).toBeNull();
|
||||
|
||||
store.clear();
|
||||
expect(store.selected).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user