Skip to content

test(text): cover the card-name and blurb display helpers#69

Open
Amayyas wants to merge 1 commit into
Younesfdj:masterfrom
Amayyas:test/text-display-helpers
Open

test(text): cover the card-name and blurb display helpers#69
Amayyas wants to merge 1 commit into
Younesfdj:masterfrom
Amayyas:test/text-display-helpers

Conversation

@Amayyas

@Amayyas Amayyas commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What

lib/text.ts runs on every card and had no tests. This adds 18, no source changes.

Same spirit as #60 — pinning pure display logic — but this module has a sharper reason to be covered: cardDisplayName isn't just a helper, it is the fix for #48 (two-word surnames vanishing from the card). Nothing guarded that fix, so a refactor could quietly bring the bug back. deEmDash rewrites the archetype blurb on the card and the OG image.

What's pinned

cardDisplayName balances one goal (show the surname) against three fallbacks, and each is nailed on both sides of its boundary — that's where the next off-by-one would hide:

  • the fix(card): fix two words not displayed bug in the card #48 regression directly: a two-word surname (Guido van Rossumvan Rossum) must render in full;
  • surname too long → first name, at 13 vs 14 chars;
  • surname too many words → first name, at 3 vs 4 words;
  • full name kept whole at 9 vs 10 chars;
  • a single unsplittable word kept whole (nothing to trim to).

deEmDash: first break → ":", later breaks → ",", the -- ASCII variant, spacing normalisation (a—b and a — b both → a: b), and that dash-free copy is left untouched.

Confidence

Mutation-checked: reintroducing the #48 bug (surname = last word only) turns two of these tests red, including the one labelled for #48 — so the guard actually guards.

255 passed (+18), lint clean, build green.

lib/text.ts runs on every card and had no tests. cardDisplayName is more
than a helper — it IS the fix for Younesfdj#48 (two-word surnames vanishing from the
card), and nothing guarded that fix, so a refactor could silently bring the
bug back. deEmDash rewrites the archetype blurb on the card and the OG image.

Pins the Younesfdj#48 regression directly (a two-word surname must render in full),
plus the three fallbacks it balances — surname too long (> 13 chars), too
many words (> 3), or a single unsplittable word kept whole — each nailed on
both sides of its boundary (9/10 name length, 13/14 surname chars, 3/4
words) where the next off-by-one would hide. For deEmDash: first break → ":"
and later breaks → ",", the "--" variant, spacing normalisation, and that
dash-free copy is left untouched.

Mutation-checked: reintroducing the Younesfdj#48 bug (surname = last word only) turns
these red.
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.

1 participant