test(text): cover the card-name and blurb display helpers#69
Open
Amayyas wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lib/text.tsruns 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:
cardDisplayNameisn'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.deEmDashrewrites 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:
Guido van Rossum→van Rossum) must render in full;deEmDash: first break →
":", later breaks →",", the--ASCII variant, spacing normalisation (a—banda — bboth →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.