12. Tests per component
- [E] Every component has contract tests that run for every entry that
has it (for example:
producesis finite and ≥ 0,combathas a hull0). A new entry is checked without new test code; its own tests cover only what is its own.
- [E] Built with #114 for the production group: the contract tests are
src/core/components/<component>.test.ts; they read every entry with the component from the generated index (rates finite and ≥ 0 for levels 0 to 60 on generated planets, nothing at level 0, one production order and one store per resource each, costs whole and never falling for levels 1 to 60).src/core/production.test.tscomparesprod()bit for bit with theprod()from before #114 on generated planets, with Fusionskraftwerk and Solarsatelliten. - [E] Built with #114 for the combat group:
src/core/components/unit.test.ts(on every ship and defense only, the cost of a piece three whole numbers ≥ 0, not all 0) andsrc/core/components/combat.test.ts(with everyunit; hull, shield and attack finite and above 0; rapid fire whole and above 1 against an entry that fights; only ships are easy).src/core/battle-reference.test.tscomparesbuildSide(),rapid()for every pair andbattle()with the same random stream, draw for draw, bit for bit withbattle.tsfrom before the combat components on generated sides. - [E] Built with #114 for the flight group:
src/core/components/mobile.test.ts(only on ships; speed above 0, cargo whole and ≥ 0, fuel whole and above 0, a known drive; drive switches to a known drive from a research level above 0; the speed finite and at least the base speed of the active drive for research levels 0 to 30).src/core/flight-reference.test.tscomparesactiveDrive(),shipSpeed(),fleetSpeed(),fuelFor(),capacity()andcanFly()bit for bit with their form before the flight component, for every key of the catalog and an unknown one, on generated fleets and research levels. - [E] Built with #114 for the limits group:
src/core/components/limit.test.ts(only on defense;perPlanetwhole and ≥ 1; the room whole, between 0 and the limit, all of it on an empty planet) andsrc/core/components/energy-threshold.test.ts(only on buildings and research; base > 0, f ≥ 1; the need finite and never falling for levels 1 to 60).src/core/limits-reference.test.tscomparesunitRoom(),orderMax()(its value or its error),energyNeed()andenergyShort()bit for bit with their form before the limits group, for every key of the catalog, an unknown one and inherited names (constructor,toString,__proto__,hasOwnProperty), on generated planets, queues and levels. - [E] Built with #114 (ProducerTable):
src/core/producer-rows.test.tschecks on generated planets, with the throttled Fusionskraftwerk, that the rows ofproducerRows()add up toprod()of the planet as it runs:f, the energy made and used bit for bit, Adamant, Psikristall and Promethium bit for bit at universe speed 1 and to 6 decimals otherwise (prod()multiplies the sum with the speed, a row each rate).src/test/catalog-keys.test.tsscanssrcwithoutsrc/features/, the tests andsrc/test/legacywith the TypeScript and Svelte parsers for comparisons with a key (the folder names undersrc/features/, withoutmissions/):===,!==,==,!=,caseandincludeson an array literal or a const bound to one. Its allow-listALLOWEDnames file, key, count and issue; the count is the number of hits of that key in that file, and the test fails when the real number is higher (a new comparison) and when it is lower (the count must be lowered), so the counts only fall and an entry goes when it reaches 0 (owner, 2026-11-14). The entriescore/lab.tslab2 andclient/logic/catalog-list.tsyard1, the lab and shipyard locks (#183, „Lab lock and shipyard lock without catalog keys“), went with the componentlocks. The generic events of #115 removed the comparisons incore/settle.ts(sat1 andenergy1) andserver/game/actions.ts(energy1 andfusion1). The mission registry of #116 removed the comparisons inserver/game/fleet-actions.tsandserver/game/arrival.ts(probe1,spy4). The report typespyinclient/views/messages.ts(1) equals a catalog key without being one and stays allowed for good, aspermanentinstead of an issue (owner, 2026-11-14). The state of a building or research that lacks energy isnoEnergy(notenergy), so the scan does not hit it (owner, 2026-11-14). - [E] Built with #115 for the generic events:
src/core/settle-reference.test.tscomparessettle()in one step and in steps,accrue(),production(), the throttled share and the planets the server settles with a frozen copy ofsettle.ts, of the throttle andaccrue()ofeconomy.tsand of the predicate ofsettleReactors()from before #115, on 300 generated planets, queues, research levels and universe speeds (fast-check seed 115), bit for bit, and checks that the cases meet every event. On the same cases settling in steps equals one step within the tolerance of #47, and a stock never goes below 0 nor grows above its storage limit.src/server/game/research-reference.test.tsstarts a research on two equal databases, with today’s action and with a frozen copy of the action before #115, and compares the answer and every table (300 cases, seed 115, every case closes its databases).src/core/settle.test.tstests each event; the contract test ofconsumesallows one entry that uses a stock. - [E] Built with #116 for the missions:
src/core/missions.test.tschecks the rules of every mission in the index (exactly the typed fields, a known target kind, the order in steps of 10 and once each,canSendgives a known code or nothing on generated fleets, one name each) and the generic target check;src/server/game/missions.test.tschecks for every mission that it has an arrival inMISSION_SERVERS, turns back from a target that does not fit its kind, flies back only if it returns, comes home silently only if silent, shows its ships only if visible (since #228: only by the Auspex-Lehre, for every mission) and takes cargo only if it carries cargo.src/server/game/missions-reference.test.tscompares sending, the arrival and the coming home with the code from before #116 on generated worlds and fleets: the answer or message, every table and the next random number.