test: Add Vitest unit tests for location-detector and country-flags helpers #232
Copy link
Copy link
Closed
Labels
Description
The geo utility module (src/lib/geo/location-detector.ts and src/lib/geo/country-flags.ts) maps user location strings to normalized country slugs and ISO flag codes using regex keyword matching, but currently lacks unit test coverage.
Motivation
Testing country normalization ensures regex boundary matching does not fail or produce false positives for similar words.
Tasks
- Create
src/lib/geo/tests/location-detector.test.ts. - Test exact match locations (e.g., 'Egypt' -> 'egypt', 'Germany' -> 'germany', 'Tokyo, Japan' -> 'japan').
- Test word boundary handling to ensure substrings don't falsely match (e.g., words containing country substrings).
- Test edge cases:
null, empty string, special characters, whitespace. - Test
getCountryCodeincountry-flags.tsfor valid and unknown slugs. - Run
pnpm testand verify all tests pass.
Tip
🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨
Reactions are currently unavailable
Activity
Ghifariezra commentedon Oct 11, 2026
assign me, i would like to take this one
github-actions commentedon Oct 11, 2026
🎉 Issue assigned to @Ghifariezra! Happy coding!