Blocked by #195 and #201.
Unit tests for the pure logic in the competitions vertical. The repo has 16 test files and 129 tests; this vertical should not be the part with none.
Setup that already exists
Vitest 4.1.9 with jsdom, @testing-library/react. vitest.config.ts includes src/**/*.test.ts and src/**/*.test.tsx, so tests are colocated next to what they test. npm run test:unit. CI runs it on every PR via the unit-tests job in .github/workflows/ci.yml.
Closest models: src/lib/places.test.ts for the filtering shape, src/lib/data-freshness.test.ts for date logic, src/components/map/results-list.test.tsx for a component test.
What to cover
src/lib/competitions.test.ts
filterCompetitions with each filter alone, and with two composed
- Age filter is inclusive at both ends of
age_min and age_max
query matches name, organizer and subjects, case-insensitively, and ignores surrounding whitespace
- Empty filters returns everything; a filter matching nothing returns an empty array, not undefined
nextDate skips past dates, returns the soonest future one, and returns undefined when all dates are past
upcomingDates sorts ascending and includes country stages only when a country is given
src/lib/competition-events.test.ts
- Flattening produces one event per date plus one per stage of the selected country only
- A competition with no
country_tracks produces only its own dates
- The
estimated flag survives flattening
- Timezone handling does not shift a date across a day boundary. Pin a fixed
now rather than using the real clock.
Date tests must not depend on when they run. check-data-freshness.mjs already accepts a --today= flag for exactly this reason. Pass an explicit now everywhere rather than letting a test pass in September and fail in January.
Acceptance criteria
Blocked by #195 and #201.
Unit tests for the pure logic in the competitions vertical. The repo has 16 test files and 129 tests; this vertical should not be the part with none.
Setup that already exists
Vitest 4.1.9 with jsdom,
@testing-library/react.vitest.config.tsincludessrc/**/*.test.tsandsrc/**/*.test.tsx, so tests are colocated next to what they test.npm run test:unit. CI runs it on every PR via theunit-testsjob in.github/workflows/ci.yml.Closest models:
src/lib/places.test.tsfor the filtering shape,src/lib/data-freshness.test.tsfor date logic,src/components/map/results-list.test.tsxfor a component test.What to cover
src/lib/competitions.test.tsfilterCompetitionswith each filter alone, and with two composedage_minandage_maxquerymatches name, organizer and subjects, case-insensitively, and ignores surrounding whitespacenextDateskips past dates, returns the soonest future one, and returns undefined when all dates are pastupcomingDatessorts ascending and includes country stages only when a country is givensrc/lib/competition-events.test.tscountry_tracksproduces only its own datesestimatedflag survives flatteningnowrather than using the real clock.Date tests must not depend on when they run.
check-data-freshness.mjsalready accepts a--today=flag for exactly this reason. Pass an explicitnoweverywhere rather than letting a test pass in September and fail in January.Acceptance criteria
npm run test:unitpassessrc/lib/, matching the existing convention