Skip to content

tests: cover untested journey.js exports and normalizeTheme edge case - #12

Open
ashishbhateja wants to merge 1 commit into
mainfrom
test/journey-normalize-coverage
Open

ashishbhateja wants to merge 1 commit into
mainfrom
test/journey-normalize-coverage

Conversation

@ashishbhateja

Copy link
Copy Markdown
Owner

What

Adds 4 new checks to scripts/smoke.mjs covering gaps in the existing test suite (19 → 23 checks).

New checks

Function What was missing What the new check asserts
monthsOfMovement Exported but never imported or tested Returns the 5 ground-movement months in calendar order (1–5)
movementOf Only the object-argument branch was tested Correctly resolves a month number (e.g. 5) to its movement
mirrorOf Only tested for the Jan⇄Dec mirrored pair Returns null for a month with no mirror (June)
normalizeTheme Used inside assertion lambdas but never directly asserted Trims surrounding whitespace and lowercases (' Integral Yoga ' → 'integral yoga')

Why

monthsOfMovement is a public, documented export that asMovements delegates to internally. Its contract (filtered, sorted by number) was only covered transitively through asMovements. A direct test pins that contract.

The movementOf overloaded-argument and mirrorOf null-return paths are plausible call sites in UI code; testing them now means a future refactor can't silently break them.

normalizeTheme's trimming behaviour matters because reader-stored interests are normalised before being compared to article themes — a leading/trailing space would silently break matching.

Checklist

  • All 23 checks pass (node scripts/smoke.mjs)
  • Build succeeds (node scripts/build.mjs content/sample-edition.json)
  • No new dependencies introduced
  • No production code changed

Generated by Claude Code

monthsOfMovement was exported but never directly tested — adds a check
that it returns months in calendar order for a given movement id.

Adds two further journey.js edge-case checks: movementOf() called with
a month number (the numeric branch of its overloaded argument), and
mirrorOf() returning null for a month with no mirror relationship (June).

Adds an explicit normalizeTheme check that verifies both lowercasing and
whitespace trimming, which were relied on throughout the test suite but
never asserted directly.

19 → 23 checks, all passing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants