Skip to content

tests: fill three genuine gaps in the smoke-test suite - #19

Open
ashishbhateja wants to merge 1 commit into
mainfrom
tests/fill-coverage-gaps
Open

ashishbhateja wants to merge 1 commit into
mainfrom
tests/fill-coverage-gaps

Conversation

@ashishbhateja

Copy link
Copy Markdown
Owner

What and why

Three assertions in scripts/smoke.mjs were either logically circular or simply absent, meaning real regressions in those code paths would go undetected by CI.

1. collectThemes — tautological assertion replaced with a concrete one

The previous check compared the result against a dedup-and-sort of itself:

assert.deepEqual(themes, [...new Set(themes)].sort());

This is always true for any already-sorted, duplicate-free array — it proves nothing about whether normalizeTheme actually collapses differently-cased variants. Because the sample edition uses consistent casing throughout, a completely broken normalizer would have passed.

The new check feeds two articles with the same theme in different casings ('Vedanta' and 'vedanta') and asserts the output contains exactly two sorted, normalised entries — not three:

check('collectThemes deduplicates themes that differ only by case', () => {
  const themes = collectThemes([
    { themes: ['Vedanta', 'Sadhana'] },
    { themes: ['vedanta'] },
  ]);
  assert.deepEqual(themes, ['sadhana', 'vedanta']);
});

2. monthsOfMovement — exported API, zero direct coverage

monthsOfMovement is exported from journey.js and called internally by asMovements, but it had no test of its own. If its sort or filter broke, the asMovements test would still pass as long as the month count was right. The new check verifies both the length and the exact calendar order of the 'ground' movement (five months, Jan–May).

3. snippet with no terms — default-parameter path untested

snippet(article, terms = []) has an explicit default of []. The existing tests only covered ['absentterm'] (a term that simply isn't found). With an empty array the inner loop never runs, which is a distinct code path. The new check confirms the fallback to the start of the text still fires correctly.

Result

19 checks → 22 checks, all passing. npm run build unaffected.


Generated by Claude Code

The previous collectThemes assertion compared the result against a
dedup-and-sort of itself — a tautology that would pass even if theme
normalisation were completely broken on the current sample data, because no
two articles shared the same theme string. Replace it with a concrete test
that feeds two articles with the same theme in different cases and asserts
exactly two normalised, sorted entries come back.

monthsOfMovement is exported from journey.js and called internally by
asMovements, but had no direct assertion of its own. Add one that checks
both the count and the calendar order of the 'ground' movement (five months,
Jan–May).

snippet(article) with an empty terms list is the natural default-parameter
path; only the 'absent term' string case was covered. Add an explicit check
that omitting terms falls back to the start of the text, matching the
existing fallback contract.

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