test(geo): cover countryForLogin and the location parser's refusals#87
Merged
Merged
Conversation
countryForLogin is what engine.ts calls to set every card's country, and it
had no tests at all — nothing pinned its pinned-origin override (torvalds →
us regardless of location), the case-insensitive login match, or the
fall-through to the location parser.
geo.test.ts already covered the UK home nations and the Georgia country-vs-
US-state split, but not the design decisions the module's own header calls
out — where a wrong guess is worse than no flag:
- ambiguous 2-letter abbreviations are refused ("DE", "CA" → null), while
the intentional "uk" → gb alias still stands;
- empty / blank / symbol-only input sanitises to null;
- native-language and colloquial aliases (Deutschland, España, Türkiye,
Holland), accented cities (München, Kraków), and multi-word phrases found
anywhere in the free text ("based in United Kingdom");
- first resolving segment wins left-to-right ("California, France" → us).
Mutation-checked: dropping the pinned override turns the countryForLogin
tests red.
Owner
|
great work, thanks @Amayyas |
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
countryForLoginis the functionengine.tscalls to set every card's country, and it had no tests. This adds coverage for it and for the location-parser contractsgeo.test.tsdidn't yet pin. +11 tests, no source changes.countryForLogin (was entirely untested)
It layers a pinned-origin override over
countryFromLocation. Now pinned:torvalds→useven with a French location);null.countryFromLocation — the deliberate refusals
geo.test.tsalready covered the UK home nations and the Georgia country-vs-US-state split. What it didn't cover were the design decisions the module's own header comment calls out — and where "a wrong guess is worse than no flag" is the whole point:DE= Germany or Delaware,CA= California or Canada →null), while the intentionaluk→gbalias still stands — so the test documents that "drop 2-letter codes" has a deliberate exception, not a bug;null;"based in United Kingdom");"California, France"→us).Confidence
Mutation-checked: dropping the pinned override turns the
countryForLogintests red.276 passed, lint clean, build green.